robmkimmons
Technical User
Hello!
I’m looking for some direction.
I believe that I’m doing “OK” on the relational data design, but am struggling with the syntax and details of the coding. I have the following tables created (see picture).
Essencially, I want a simple form with two unbound text boxes, [txtBadgeScan] and [txtItemScan]. If the item has not been previously checked-out by this associate then automatically check it out. However, if it has been previously checked-out, then check it back in.
Here’s my attempt:
Private Sub txtItemScan_AfterUpdate(Cancel As Integer)
Dim ItemScan As Variant
Dim ActionChoice As Variant
If Me.txtItemScan.Value = DLookup("AID", "tblTransactions", _
"[AID]=" & Me.txtItemScan.Value) And _
Me.txtBadgeScan.Value = DLookup(“AssocID”,tblTransactions”,_
“[AssocID]=”& Me.txtBadgeScan.Value) And_
Then
‘What do I do from here?
‘ This is where I don’t know what to do?
‘How do I create a new record in tblTransactions and give its _
‘ActionID field either a “1” Check-out or a “2” Check-in?
Couple of additional questions:
1) Should this form frmTransactions be unbound or bound to tblTransactions?
2) Would Case If in the coding be more efficient/effective?
Thank you for any input!
~Rob
If we expect the unexpected, does that make the unexpected... well, expected?
I’m looking for some direction.
I believe that I’m doing “OK” on the relational data design, but am struggling with the syntax and details of the coding. I have the following tables created (see picture).

Essencially, I want a simple form with two unbound text boxes, [txtBadgeScan] and [txtItemScan]. If the item has not been previously checked-out by this associate then automatically check it out. However, if it has been previously checked-out, then check it back in.
Here’s my attempt:
Private Sub txtItemScan_AfterUpdate(Cancel As Integer)
Dim ItemScan As Variant
Dim ActionChoice As Variant
If Me.txtItemScan.Value = DLookup("AID", "tblTransactions", _
"[AID]=" & Me.txtItemScan.Value) And _
Me.txtBadgeScan.Value = DLookup(“AssocID”,tblTransactions”,_
“[AssocID]=”& Me.txtBadgeScan.Value) And_
Then
‘What do I do from here?
‘ This is where I don’t know what to do?
‘How do I create a new record in tblTransactions and give its _
‘ActionID field either a “1” Check-out or a “2” Check-in?
Couple of additional questions:
1) Should this form frmTransactions be unbound or bound to tblTransactions?
2) Would Case If in the coding be more efficient/effective?
Thank you for any input!
~Rob
If we expect the unexpected, does that make the unexpected... well, expected?