Another Autofill Question

R

rocketD

Sorry if this is redundant, I couldn't find quite what I needed.

I have a form which has 3 unbound combo boxes: UWW, WBS, and D7i
(order#). The boxes select IDs from built-in queries. Together, these
3 values make up a unique record. When the user selects the values,
if they are a unique combination, my code enters a record into a
bridge table which links all three (bridgeID, uwwID, wbsID, orderID).

What I want in the parent table which all the form data goes into is
the bridgeID number (which is the unique identifier for the
combination of the three fields) NOT the info in the three fields. I
have the bridgeID field in the form as invisible with no tab stop, but
I don't know how to code it so that it selects the bridgeID
corresponding to the three fields in the form. I think I should put
the code into the afterupdate() event on the last of the three fields,
the "D7i" field, but I don't know what code to use. Any ideas?

This is the code for the last field:

'If D7i is not in the list for the UWW in the current invoice, add it.
Private Sub workorder_NotInList(NewData As String, Response As
Integer)

Dim ctl As Control
Dim strSQL As String
Set ctl = Me!workorder

If MsgBox("Value is not in list. Add it?", _
vbOKCancel) = vbOK Then

Response = acDataErrAdded

strSQL = "INSERT INTO lkpWorkOrder(D7i, uwwID) VALUES('"
strSQL = strSQL & NewData & "', " & Me.uww & ");"
CurrentDb.Execute strSQL
Debug.Print strSQL

Else
Response = acDataErrContinue
ctl.Undo
End If

'If the current combination of UWW, WBS and D7i has never been
recorded, add it.
strSQL = "INSERT INTO brgAFE(uwwID, wbsID, orderID) VALUES('"
strSQL = strSQL & Me.uww & "', '" & Me.wbs & "', '" & Me.workorder &
"');"
CurrentDb.Execute strSQL
Debug.Print strSQL

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top