I'm having issues with this code. Getting an error. "Cant find field '|1' reffered to in your expresstion" Here's the code I'm using. Trying to check a table to see if a record exists with the specific user id and weeknumber.
Private Sub NextToMeals_Click()
Dim Id As Integer, wkNum1 As Integer, wkNum2 As Integer, Status As String, lookupwk1 As Integer, lookupwk2 As Integer
Me.SelectUserID = Id
wkNum1 = 1
wkNum2 = 2
lookupwk1 = DLookup("[WeekNumber]", "Standard_Actions", "[UserID]= Id " And [WeekNumber] = wkNum1)
lookupwk2 = DLookup("[WeekNumber]", "Standard_Actions", "[UserID]= Id " And [WeekNumber] = wkNum2)
If lookupwk1 = wkNum1 Then
If lookupwk2 = wkNum2 Then
MsgBox "You have already created a plan for this user. If you would like to edit week one, select 'Edit Existing User' in the Main Menu.", vbOKOnly
DoCmd.OpenForm "MainMenu", acNormal
DoCmd.Close acForm, "FRM_Select_Users"
Else
DoCmd.OpenForm "FRM_Edit_Standard_Actions", acNormal, , , acFormEdit
Form_FRM_Edit_Standard_Actions.UserID.Value = Id
Form_FRM_Edit_Standard_Actions.WeekNumber.Value = wkNum1
Form_FRM_Edit_Standard_Actions.RiseTime.SetFocus
DoCmd.Close acForm, "FRM_Select_Users"
End If
Else
DoCmd.OpenForm "FRM_Edit_Standard_Actions", acNormal, , , acFormEdit
Form_FRM_Edit_Standard_Actions.UserID.Value = Id
Form_FRM_Edit_Standard_Actions.WeekNumber.Value = wkNum1
Form_FRM_Edit_Standard_Actions.RiseTime.SetFocus
DoCmd.Close acForm, "FRM_Select_Users"
End If
End Sub
Dim Id As Integer, wkNum1 As Integer, wkNum2 As Integer, Status As String, lookupwk1 As Integer, lookupwk2 As Integer
Me.SelectUserID = Id
wkNum1 = 1
wkNum2 = 2
lookupwk1 = DLookup("[WeekNumber]", "Standard_Actions", "[UserID]= Id " And [WeekNumber] = wkNum1)
lookupwk2 = DLookup("[WeekNumber]", "Standard_Actions", "[UserID]= Id " And [WeekNumber] = wkNum2)
If lookupwk1 = wkNum1 Then
If lookupwk2 = wkNum2 Then
MsgBox "You have already created a plan for this user. If you would like to edit week one, select 'Edit Existing User' in the Main Menu.", vbOKOnly
DoCmd.OpenForm "MainMenu", acNormal
DoCmd.Close acForm, "FRM_Select_Users"
Else
DoCmd.OpenForm "FRM_Edit_Standard_Actions", acNormal, , , acFormEdit
Form_FRM_Edit_Standard_Actions.UserID.Value = Id
Form_FRM_Edit_Standard_Actions.WeekNumber.Value = wkNum1
Form_FRM_Edit_Standard_Actions.RiseTime.SetFocus
DoCmd.Close acForm, "FRM_Select_Users"
End If
Else
DoCmd.OpenForm "FRM_Edit_Standard_Actions", acNormal, , , acFormEdit
Form_FRM_Edit_Standard_Actions.UserID.Value = Id
Form_FRM_Edit_Standard_Actions.WeekNumber.Value = wkNum1
Form_FRM_Edit_Standard_Actions.RiseTime.SetFocus
DoCmd.Close acForm, "FRM_Select_Users"
End If
End Sub