brewpedals
Registered User.
- Local time
- Today, 15:26
- Joined
- Oct 16, 2002
- Messages
- 32
Hi,
Thanks for your help!
I have a Function that is intended to toggle a boolean field in a subforms recordset. If call the function with the commented SQL with a descrete record number, it works perfectly, but does not when I use the declared variable. Is Long the wrong data type for an autonumber?
CODE:
++++++++++++++++++++++++++++++++++++++++++++++++++++++
Public Function ToggleIFC()
Dim CurRec As Long
' Stores the value of F_Main_subform's current record in the variable CurRec.
CurRec = Form_F_Main_subform.CurrentRecord
' Executes an Update Query to toggle the IFC field in the current record.
' DoCmd.RunSQL "UPDATE PD_Requests SET PD_Requests.IFC = IIf([PD_Requests].[IFC]=Yes,No,IIf([PD_Requests].[IFC]=No,Yes,No))WHERE (((PD_Requests.Request_No)=63));"
DoCmd.RunSQL "UPDATE PD_Requests SET PD_Requests.IFC = IIf([PD_Requests].[IFC]=-1,0,IIf([PD_Requests].[IFC]=0,-1,0))WHERE (((PD_Requests.Request_No)= " & CurRec & " ));"
End Function
Thanks for your help!
I have a Function that is intended to toggle a boolean field in a subforms recordset. If call the function with the commented SQL with a descrete record number, it works perfectly, but does not when I use the declared variable. Is Long the wrong data type for an autonumber?
CODE:
++++++++++++++++++++++++++++++++++++++++++++++++++++++
Public Function ToggleIFC()
Dim CurRec As Long
' Stores the value of F_Main_subform's current record in the variable CurRec.
CurRec = Form_F_Main_subform.CurrentRecord
' Executes an Update Query to toggle the IFC field in the current record.
' DoCmd.RunSQL "UPDATE PD_Requests SET PD_Requests.IFC = IIf([PD_Requests].[IFC]=Yes,No,IIf([PD_Requests].[IFC]=No,Yes,No))WHERE (((PD_Requests.Request_No)=63));"
DoCmd.RunSQL "UPDATE PD_Requests SET PD_Requests.IFC = IIf([PD_Requests].[IFC]=-1,0,IIf([PD_Requests].[IFC]=0,-1,0))WHERE (((PD_Requests.Request_No)= " & CurRec & " ));"
End Function