Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8128595
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T07:56:49+00:00 2026-06-06T07:56:49+00:00

I’m writing an Access database. I have a number of forms that are identical.

  • 0

I’m writing an Access database. I have a number of forms that are identical. These are used to edit look up lists for different fields in my main contacts table.

e.g. there is a company field and a country field. The forms that open for each editable list are identical with repeat vba code in each becasue I cannot work out how to reference the active table from the active form.

The code I currently have for clearing all the yes/no boxes in the table is:

Private Sub cmdClearTicks_Click()

    Dim db As Database
   ' Dim sel  As Control

    Set db = CurrentDb
    ' Clear all ticks of selected records
    db.Execute "UPDATE ContactCompany " _
        & "SET Selected = null "


    ' Update Selected Field
   Me.Requery

End Sub

ContactCompany is the name of the table. I would like to be able to set this sub globally but cannot work out what I should replace ContactCompany with to reference the table in the currently open form. I’ve already tried Me.RecordSource which does not work.

I’m very grateful for what I assume is a very easy fix!

Sean posted a great fix below. I’m now stumped with including a filter too and defining it globaly.

Sub SelectFiltered(RS As String)

Dim strFilter As String
Dim strSQl As String

If InStr(RS, "FROM") Then
    RS = Mid(RS, InStr(RS, "FROM") + 5)
    If InStr(RS, " ") Then RS = Left(RS, InStr(RS, " ") - 1)
End If

strFilter = Me.Filter

If Me.FilterOn = False Then

'Select Case MsgBox("No search or filter applied.", vbCritical + vbOKOnly, "Warning")
'End Select

strSQl = "UPDATE " & RS & " " & _
"SET Selected = 1 "

Else

strSQl = "UPDATE " & RS & " " & _
"SET Selected = 1 " & _
"WHERE " & strFilter

End If

DoCmd.SetWarnings False
DoCmd.RunSQL strSQl
DoCmd.SetWarnings True

End Sub

Me.filter doesn’t work in the global sub. Sean – I’m sure you’ll have an answer for this in a sec. Thanks again!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T07:56:52+00:00Added an answer on June 6, 2026 at 7:56 am

    you are close with using Me.Recordsource

    db.Execute "UPDATE " & Me.Recordsource & " SET Selected = null "
    or, if you want it as a global function, pass Me.Recordsource to it

    Sub ClearTicks(RS as string,StrFilter as string)
    
        Dim db As Database
        Set db = CurrentDb
    
        If InStr(RS, "FROM") Then 
            RS = Mid(RS, InStr(RS, "FROM") + 5)
            If InStr(RS, " ") Then RS = Left(RS, InStr(RS, " ") - 1)
        End If
    
        ' Clear all ticks of selected records
        db.Execute "UPDATE " & RS & " SET Selected = null "
    
        If StrFilter="" then 'no filter
        Else 'filter
        End If
    End Sub
    

    and your calling function would be:

    Private Sub cmdClearTicks_Click()
        ClearTicks Me.Recordsource,Me.Filter
        Me.Refresh
    End Sub
    

    If you want a more reusable function method that could be expanded more easily, then call the sub/function with Me.Name as the parameter (e.g. MySub Me.Name) and then in your reusable function:

    sub MySub(FrmName as string)
    Forms(FrmName).Filter
    Forms(FrmName).Recordsource
    Forms(FrmName).AnyOtherParamater
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a small JavaScript validation script that validates inputs based on Regex. I
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a view passing on information from a database: def serve_article(request, id): served_article
I have a reasonable size flat file database of text documents mostly saved in
Let's say I'm outputting a post title and in our database, it's Hello Y’all
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.