I have a form that I fill in some initial data into a MASTER table.
At a later time, I need to update some date information in this table. In order to do this, I have to know some of the original data like Lot Number and Part Number. It is date/time stamped.
So the second subform. I will scan in the lot # and then have the form look up the lot # and assign the new data.
ok I think I can do this, you need to assign the lot# to a variable, and then run a recordset to look for that lot# in the master table, then if it is found you need to do an update recordset on the master table using the dates as vb variables too.
Yep no worries mate, just finished work but I will get on to it at home, supply me with what you have already written that way I don't have to learn the names of your text fields.
I hope you going to give me a star for this I might miss friends.
In the after update event of the TxtStart in your second unbound form do this:
Dim start, lot, strSQL as string
Dim rst as ADODB.Recordset
start = TxtStart
lot = TxtLot
strSQL = "SELECT * FROM Master
WHERE Master.Lot_Number = '" & lot & "'"
set rst = New ADODB.recordset
rst.Open strSQL, CurrentProject.Connection, adOpenkeyset, adLockOptimistic
if (Not rst.EOF) then
'run update query here
end if
rst.close
Dim start, lot, strSQL As String
Dim rst As ADODB.Recordset
Dim rst2 As ADODB.Recordset
start = TxtStart
lot = TxtLot
strSQL = "SELECT * FROM Master WHERE Master.LotNumber = " & lot & ""
Set rst = New ADODB.Recordset
rst.Open strSQL, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
If (Not rst.EOF) Then
strSQL = "UPDATE Master SET StartDate = '" & start & "'"
Set rst2 = New ADODB.Recordset
rst2.Open strSQL, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
End If
rst.Close
Dim start, lot, strSQL As String
Dim rst As ADODB.Recordset
Dim rst2 As ADODB.Recordset
start = TxtStart
lot = TxtLot
Part = TxtPart
strSQL = "SELECT * FROM Master WHERE Master.LotNumber = " & lot & " and Master.PartNumber = '" & Part & "'"
Set rst = New ADODB.Recordset
rst.Open strSQL, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
If (Not rst.EOF) Then
strSQL = "UPDATE Master SET Start = '" & start & "'"
DoCmd.RunSQL strSQL
End If
rst.Close
I had to add another criteria to the select statement.
BUT, it updated all my fields in the table with the START time, not just the field based on the query.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.