Problem with adding record

mosh

Registered User.
Local time
Today, 14:58
Joined
Aug 22, 2005
Messages
133
Hi All,

I seem to have a problem with my ordering form, when I add a record the following appears:

"Syntax error (missing operator) in query expression 'Staff_id='

Private Sub Form_Current()
Me.employee_lan.Value = DLookup("employee_lan", "tblStaff", "Staff_id=" & Me.staff_id)
Dim Emp, Lan As String
Lan = GetWorkstationLan
Emp = DLookup("[Employee_Name]", "[tblStaff]", "[Employee_Lan] = '" & Lan & "'")
If Me.employee_lan.Value = Emp Or Me.employee_lan = Lan Or IsNull(Me.employee_lan) Then
EnableEverything
Me.employee_lan = Emp
Else:
DisableEverything
End If
End Sub

help appreciated.

Thanks
________
Sweettitis cam
 
Last edited:
Is staff_id an AutoNumber field? Has it been assigned to the record yet? AutoNumber fields do not get assigned until the record is Dirty for some other reason. Your error indicates that the staff_id field is still a Null.
 
Is staff_id an AutoNumber field? Has it been assigned to the record yet? AutoNumber fields do not get assigned until the record is Dirty for some other reason. Your error indicates that the staff_id field is still a Null.

staff_id is an autonumber field, but is already assigned a value in this case. lI also have another problem; the form uses the LANID of the staff on the form, but the problem is when i create a new record it also creates a new record in tblStaff when it shouldn't. Based on the LAN the form should lookup which employee is adding the record and then use the employee in question, but for some reason a new employee is created in staff (data is saved in employee_lan)

Private Sub Form_Current()
'Me.employee_lan.Value = DLookup("employee_name", "tblStaff", "[Staff_id]='" & Me.staff_id)
Dim Emp, Lan As String
Lan = GetWorkstationLan
Emp = DLookup("[Employee_Name]", "[tblStaff]", "[Employee_Lan] = '" & Lan & "'")
If Me.employee_lan = Emp Or Me.employee_lan = Lan Or IsNull(Me.employee_lan) Then
EnableEverything
Me.employee_lan = Emp
Else:
DisableEverything
End If
End Sub

^ This is the code i have for the oncurrent of the form.

HTH
________
NazteeSarah live
 
Last edited:
Have you put a BreakPoint on the code so you can single step it to see what values are being used?
 

Users who are viewing this thread

Back
Top Bottom