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

  • Home
  • SEARCH
  • 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 3788242
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T11:58:05+00:00 2026-05-19T11:58:05+00:00

I have a table in Access.. AccessKey AccessCardID Distributed (yes/no) On my form is

  • 0

I have a table in Access..
AccessKey
AccessCardID
Distributed (yes/no)

On my form is a combo box with 10 Access Cards. I need help setting up a query where if guest A gets Access Card #1, the user will only be able to choose from Access Cards #2-#10, for guest B, c, and so on, until guest A returns Access Card #1.
so far the the query i have is

SELECT AccessCardID  
FROM AccessKey  
WHERE Distributed = False;  

Here is my new code for After update

Private Sub AccessKeyNo_AfterUpdate()
If MsgBox("Do you want to assign Access Key" & Me.AccessKeyNo & "?", _
        vbYesNo) = vbYes Then
    Me.GuestAccessKeyID = Me.AccessKeyNo
    Me.MyCheckBox = Not IsNull(Me.GuestAccessKeyID)
    Me.AccessKeyNo.Requery
End If
End Sub

My new query

SELECT AccessKey.AccessKeyID
FROM AccessKey LEFT JOIN Guest ON AccessKey.AccessKeyID=Guest.GuestAccessKeyID
WHERE (((Guest.GuestAccessKeyID) Is Null));

And the On current for the form

Private Sub Form_Current()
Me.MyCheckBox = Not IsNull(Me.GuestAccessKeyID)

If IsNull(Me![GuestID]) Then
DoCmd.GoToControl "GuestFirstName"
End If
End Sub
  • 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-05-19T11:58:05+00:00Added an answer on May 19, 2026 at 11:58 am

    If you do not like writing code, you can use a subform and set the record source to your table, AccessKey. Alternatively you can write a little code, say:

    Private Sub NameOfComboHere_AfterUpdate()
    Dim db As Database
    Dim strSQL As String
    
    Set db = CurrentDb
        If MsgBox("Do you want to assign " & Me.NameOfComboHere & "?", _
                vbYesNo) = vbYes Then
            strSQL = "UPDATE AccessKey SET Distributed = True " _
                & "WHERE AccessCardID = " & Me.NameOfComboHere
            db.Execute strSQL, dbFailOnError
            If db.RecordsAffected = 1 Then
                MsgBox Me.NameOfComboHere & " has been assigned."
            End If
        End If
    
        Me.NameOfComboHere.Requery
    End Sub
    

    There are a few notes. This assumes that the combobox has a bound column of AccessCardID and that AccessCardID is numeric. It also assumes that you have a reference to Microsoft DAO 3.x Object library. A subform may be the best bet.

    EDIT based on Comments

    Let us say you have a card id in the guest table, first, add a little code to the Current event for the form:

    Me.MyCheckBox = Not IsNull(Me.GuestAccessCard)
    

    This will set the checkbox to false if there is no card id and to true if there is an id.

    You will need to change the query for the combobox to:

    SELECT AccessCardID 
    FROM AccessKey 
    LEFT JOIN Guests 
    ON AccessKey.AccessCardID = Guest.GuestAccessCard
    WHERE Guest.GuestAccessCard Is Null
    

    Then the After Update event would run:

    Private Sub NameOfComboHere_AfterUpdate()
        If MsgBox("Do you want to assign " & Me.NameOfComboHere & "?", _
                vbYesNo) = vbYes Then
            Me.GuestAccessCard = Me.NameOfComboHere
            Me.MyCheckBox = Not IsNull(Me.GuestAccessCard)
            ''The data will have to be saved for the
            ''combo to update with the new data
            If Me.Dirty Then Me.Dirty = False
            Me.NameOfComboHere.Requery
        End If
    
    End Sub
    

    And do not forget to set the GuestAccessCard to Null when the checkbox is unticked and requery the combo.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have got a table in MS Access 2007 with 4 fields. Labour Cost
I have the table (Product_Id, category priority, atribute1, atribute2...) in MS Access, and I
I have a legacy MS Access 2007 table that contains 52 fields (1 field
I have a field on a table in MS Access, tblMyTable.SomeID, and I want
I have an Access database in which I drop the table and then create
I have an Access 2002 application which links an Oracle table via ODBC with
If I have a class representing access to one table in my database in
I have a table containing access logs. I want to know how many accesses
Using MS Access 2007, I am creating a student management database. I have tables
If I have a collection of database tables (in an Access file, for example)

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.