T
Todd
I have a data entry form which records status information
to a status table.
For some particular status entries, I also need to update
another table. I'm thinking that using the AfterUpdate
event should work for this...so I would have code to check
if a certain status condition is met, and then update my
other table if it is true. I know how to do most of this,
but the tricky part (for me) is finding the right place in
the other table to make the update. Basically, I need to
compare one field from the status entry to the other table
and then update a field in that record based on another
field from the status entry. Below is the beginnings of
the code that I think will work. I've put some comments
in ALL CAPS where I've got uncertainties:
Private Sub Form_AfterUpdate()
'Check for proper status condition
If Me.Combo18 = "Frozen" Then
Dim rs As DAO.Recordset
Dim LOT As String
Dim Vessel As String
LOT = Me.Combo23
Vessel = Me.Combo12
HERE IS WHERE I RUN IN TO TROUBLE. I NEED TO SEARCH
TABLE "TEST" TO FIND WHERE LOT MATCHES A FIELD CALLED
BIN. IF LOT MATCHES BIN, THEN I WANT THE "VESSEL" VALUE
TO BE UPDATED IN THE FIELD IN "TEST" CALLED "VessNum".
THE BELOW CODE SHOULD UPDATE THE FIELD, BUT AGAIN, I DON'T
KNOW HOW TO FIND THE RIGHT FIELD.
Set rs = DBEngine(0)(0).OpenRecordset("Test",
dbOpenDynaset)
With rs
![VessNum] = Vessel
.Update
End With
rs.Close
Set rs = Nothing
End If
End Sub
Thanks in advance for any help.
Note: if there is a better way to do this, please let me
know.
to a status table.
For some particular status entries, I also need to update
another table. I'm thinking that using the AfterUpdate
event should work for this...so I would have code to check
if a certain status condition is met, and then update my
other table if it is true. I know how to do most of this,
but the tricky part (for me) is finding the right place in
the other table to make the update. Basically, I need to
compare one field from the status entry to the other table
and then update a field in that record based on another
field from the status entry. Below is the beginnings of
the code that I think will work. I've put some comments
in ALL CAPS where I've got uncertainties:
Private Sub Form_AfterUpdate()
'Check for proper status condition
If Me.Combo18 = "Frozen" Then
Dim rs As DAO.Recordset
Dim LOT As String
Dim Vessel As String
LOT = Me.Combo23
Vessel = Me.Combo12
HERE IS WHERE I RUN IN TO TROUBLE. I NEED TO SEARCH
TABLE "TEST" TO FIND WHERE LOT MATCHES A FIELD CALLED
BIN. IF LOT MATCHES BIN, THEN I WANT THE "VESSEL" VALUE
TO BE UPDATED IN THE FIELD IN "TEST" CALLED "VessNum".
THE BELOW CODE SHOULD UPDATE THE FIELD, BUT AGAIN, I DON'T
KNOW HOW TO FIND THE RIGHT FIELD.
Set rs = DBEngine(0)(0).OpenRecordset("Test",
dbOpenDynaset)
With rs
![VessNum] = Vessel
.Update
End With
rs.Close
Set rs = Nothing
End If
End Sub
Thanks in advance for any help.
Note: if there is a better way to do this, please let me
know.