I have 2 Tables i am using
Table1 = COCTL
Fields = Id, CusIdAuto, CusIdLast
This table only has 1 record and should never have more than that it controls the customer number for table COCUS. CusIdAuto is the increment value i want to increment CudIdLast by every time i make a new record in COCUS.
Table2 = COCUS
Fields = CusId
There are more fields than this but there really not relevant to the problem.
I want to run some code beofore insert on a form that contains COCUS record information the code will take the value from Table COCTL field CusIdLast and
CusIdAuto add them together and make that the CusId for COCUS table and then change the value of CusIdLast to what it just set the value of CusId to.
I think just showing you the code will make it more clear.
Private Sub Form_BeforeInsert(Cancel As Integer)
Me!CusId = DLookup("CusIdLast", "COCTL") + DLookup("CusIdAuto", "COCTL")
[COCTL]![CusIdLast] = Me!CusId
End Sub
I know this code won't work the first part will work fine it's the last part i have problems with. I just don't know how to set a value in a field that is not the current table(recordset).
Thanks in advance,
Tim
Table1 = COCTL
Fields = Id, CusIdAuto, CusIdLast
This table only has 1 record and should never have more than that it controls the customer number for table COCUS. CusIdAuto is the increment value i want to increment CudIdLast by every time i make a new record in COCUS.
Table2 = COCUS
Fields = CusId
There are more fields than this but there really not relevant to the problem.
I want to run some code beofore insert on a form that contains COCUS record information the code will take the value from Table COCTL field CusIdLast and
CusIdAuto add them together and make that the CusId for COCUS table and then change the value of CusIdLast to what it just set the value of CusId to.
I think just showing you the code will make it more clear.
Private Sub Form_BeforeInsert(Cancel As Integer)
Me!CusId = DLookup("CusIdLast", "COCTL") + DLookup("CusIdAuto", "COCTL")
[COCTL]![CusIdLast] = Me!CusId
End Sub
I know this code won't work the first part will work fine it's the last part i have problems with. I just don't know how to set a value in a field that is not the current table(recordset).
Thanks in advance,
Tim