N
naigy via AccessMonster.com
Hi All,
I am using the below code in a database which we use to do repairs to devices.
This snipet of code is checking if the device requires a battery replacement
but we are increasing our products and I need to include an Or kind of
statement on the first Line so that it will check for "Device 1" Or "Device
2" Or "Device 3" however when I try to use the Or command for this purpose it
doesn't work and spits up an Runtime 13 error - Type Mismatch. Can someone
please advise how best to do this. I know I could have as part of my First
Else Then if Device 2 (repeat all code) then as part of that Else have If
Device 3 then (repeat all code again). Is a "GoTo" an option and if so how
should I set that up.
The reason I need a device filter is because this does not apply to all
products. Really only the first line of code I think is relevant but I
included the whole function just in case. From what I can see in the Access
Help "Or" can only be used for two conditions but I can't even get it to work
for that
Private Sub Serial_AfterUpdate()
If Me.DeviceRepaired.Value = "Device 1" Then
Me.SubBattMaintCheck.Form.Requery
If Me!SubBattMaintCheck.Form!MaxOfDateDue <= Date Then
Dim Msg, Style, Title, Response
Msg = "This unit requires battery replacement. Press Yes to Automatically
open battery maintenance form or No to ignore" ' Define message.
Style = vbYesNo + vbCritical + vbDefaultButton2 ' Define buttons.
Title = "Battery Maintenance Required" ' Define title.
Response = MsgBox(Msg, Style, Title)
If Response = vbYes Then ' User chose Yes.
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "BatteryLog"
stLinkCriteria = "[SerialNumber]=" & "'" & Me![Serial] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
Cancel = True ' Perform some action.
End If
End If
End If
I am using the below code in a database which we use to do repairs to devices.
This snipet of code is checking if the device requires a battery replacement
but we are increasing our products and I need to include an Or kind of
statement on the first Line so that it will check for "Device 1" Or "Device
2" Or "Device 3" however when I try to use the Or command for this purpose it
doesn't work and spits up an Runtime 13 error - Type Mismatch. Can someone
please advise how best to do this. I know I could have as part of my First
Else Then if Device 2 (repeat all code) then as part of that Else have If
Device 3 then (repeat all code again). Is a "GoTo" an option and if so how
should I set that up.
The reason I need a device filter is because this does not apply to all
products. Really only the first line of code I think is relevant but I
included the whole function just in case. From what I can see in the Access
Help "Or" can only be used for two conditions but I can't even get it to work
for that
Private Sub Serial_AfterUpdate()
If Me.DeviceRepaired.Value = "Device 1" Then
Me.SubBattMaintCheck.Form.Requery
If Me!SubBattMaintCheck.Form!MaxOfDateDue <= Date Then
Dim Msg, Style, Title, Response
Msg = "This unit requires battery replacement. Press Yes to Automatically
open battery maintenance form or No to ignore" ' Define message.
Style = vbYesNo + vbCritical + vbDefaultButton2 ' Define buttons.
Title = "Battery Maintenance Required" ' Define title.
Response = MsgBox(Msg, Style, Title)
If Response = vbYes Then ' User chose Yes.
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "BatteryLog"
stLinkCriteria = "[SerialNumber]=" & "'" & Me![Serial] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
Cancel = True ' Perform some action.
End If
End If
End If