J
Jan Il
Hi all - Access 2002 , Windows ME
I have a data entry form used to enter inspections. When I
enter a date in just the 1 year or 2 year control, I get
an error message that says:
Run-Time error 3075
Syntax error in date in query expressiion '[Equip ID]
="19B" And [Monthly]=##
I now have the code below in the Save button.
*******************************
Private Sub cmdSaveRec_Click()
'On Error GoTo Err_cmdSaveRec_Click
If DCount("*", "[Wayside Switch Inspections]", "[Equip ID]
=""" & Me.[Equip ID] & """ And [Monthly]=#" & Me.Monthly
& "#") = 0 Then
DoCmd.DoMenuItem acFormBar, acRecordsMenu,
acSaveRecord, , acMenuVer70
Me!Monthly.DefaultValue = """" & Me!Monthly & """"
DoCmd.GoToRecord , , acNewRec
Me![Equip ID].SetFocus
Else
MsgBox "This Record Already Exists",
vbExclamation, "Record Already Exists"
End If
Exit_cmdSaveRec_Click:
Exit Sub
Err_cmdSaveRec_Click:
MsgBox Err.Description
Resume Exit_cmdSaveRec_Click
End Sub
*****************************
When I do the debug, it highlights the line with the
If DCount("*", "[Wayside Switch Inspections]", "[Equip ID]
=""" & Me.[Equip ID] & """ And [Monthly]=#" & Me.Monthly
& "#") = 0 Then
I know what the problem is, but, I just can't figure out
the right syntax to add the correct work around.
What I need to do is add a part to the existing code that
will allow the 1 yr and 2 year inspections, which not not
include the monthly and quarterly inspections. Thus, there
will be entry in those controls to record. I think I just
need to add something to the effect that if there is no
entry in the monthly or quarterly controls, then it can go
ahead and save the 1 year or 2 year inspections. I have
tried to add the modification, but, I can't seem to find
the right code combination for this. Perhaps I need to
just redo the whole code. Or, modify the first part. I am
not sure.
I have checked out the Help files, and tried several of
the examples, but, so far I'm still coming up with errors.
I would appreciate it if someone could advise me as to
the 'type' of work around I need, such an If, Else, Maybe,
Whatever, or some other type of combination. That is the
part I am stumbling on mostly. I have not done this kind
of modification and I can't find the right format that
fits the need.
I would truly appreciate any suggestions.
Best regards,
Jan
I have a data entry form used to enter inspections. When I
enter a date in just the 1 year or 2 year control, I get
an error message that says:
Run-Time error 3075
Syntax error in date in query expressiion '[Equip ID]
="19B" And [Monthly]=##
I now have the code below in the Save button.
*******************************
Private Sub cmdSaveRec_Click()
'On Error GoTo Err_cmdSaveRec_Click
If DCount("*", "[Wayside Switch Inspections]", "[Equip ID]
=""" & Me.[Equip ID] & """ And [Monthly]=#" & Me.Monthly
& "#") = 0 Then
DoCmd.DoMenuItem acFormBar, acRecordsMenu,
acSaveRecord, , acMenuVer70
Me!Monthly.DefaultValue = """" & Me!Monthly & """"
DoCmd.GoToRecord , , acNewRec
Me![Equip ID].SetFocus
Else
MsgBox "This Record Already Exists",
vbExclamation, "Record Already Exists"
End If
Exit_cmdSaveRec_Click:
Exit Sub
Err_cmdSaveRec_Click:
MsgBox Err.Description
Resume Exit_cmdSaveRec_Click
End Sub
*****************************
When I do the debug, it highlights the line with the
If DCount("*", "[Wayside Switch Inspections]", "[Equip ID]
=""" & Me.[Equip ID] & """ And [Monthly]=#" & Me.Monthly
& "#") = 0 Then
I know what the problem is, but, I just can't figure out
the right syntax to add the correct work around.
What I need to do is add a part to the existing code that
will allow the 1 yr and 2 year inspections, which not not
include the monthly and quarterly inspections. Thus, there
will be entry in those controls to record. I think I just
need to add something to the effect that if there is no
entry in the monthly or quarterly controls, then it can go
ahead and save the 1 year or 2 year inspections. I have
tried to add the modification, but, I can't seem to find
the right code combination for this. Perhaps I need to
just redo the whole code. Or, modify the first part. I am
not sure.
I have checked out the Help files, and tried several of
the examples, but, so far I'm still coming up with errors.
I would appreciate it if someone could advise me as to
the 'type' of work around I need, such an If, Else, Maybe,
Whatever, or some other type of combination. That is the
part I am stumbling on mostly. I have not done this kind
of modification and I can't find the right format that
fits the need.
I would truly appreciate any suggestions.
Best regards,
Jan