patkeaveney
Registered User.
- Local time
- Today, 07:19
- Joined
- Oct 12, 2005
- Messages
- 75
Hi All
Table relationships:
the table FOIRequests is linked to the Exemptions table via a link table in a many to many relationship
FOIrequests: PK intFOIRequestsID
Link Table: intFOIRequestsID
intExemptionID
Exemptions Table PK intExemptionID
The main form opens and displays only a combo box of existing Request Numbers.
The user selects a request number and the data for the selected request is displayed.
The main form (tblFOIRequests) has several tabs and one of the tabs has a subform (tblExemptions), if more than one record exists in the sub form i need to update a field (flgExemptionsFlag) in the main record (tblFOIRequests) without user input.
The rest of the main record, which is spread over the other tabs is saved using a save button on the form, giving the user the choice to save or not.
I need to update this one field in the main record using code as i dont want the forms dirty property to be set when this field is updated
intFOIrequestID is the PK of the FOIRequests table (autonumber in design)
Table Name to be updated: FOIRequests
Field Name in table: flgExemptionsFlag (yes/no field in table design)
sub RecordCount
Dim SubFormRecordCountExemp As Long
Dim ExemptionFlag As Variant (not sure if this is correct)
' Subform Exemptions
Set rs = Me.frmExemptionListsubform.Form.RecordsetClone
If Not (rs.EOF) Then
rs.MoveLast
End If
SubFormRecordCountExemp = rs.RecordCount
If SubFormRecordCountExemp > 0 Then
ExemptionFlag = -1
Else
ExemptionFlag = 0
End If
Set rs = Nothing
' Main form
Set rs = Me.RecordsetClone
If Not (rs.EOF) Then
rs.MoveLast
End If
FormRecordCount = rs.RecordCount
DoCmd.RunSQL "UPDATE [tblFOIRequests] SET flgExemptionFlag = '" & ExemptionFlag & "' WHERE tblFOIRequests.intFOIRequestID = '" & [Forms]![frmAmendRequest]![intFOIRequestID] & "'"
End Sub
When running the above code I get the error: data type mismatch in criteria expression:
Thanks in advance
Pat
Table relationships:
the table FOIRequests is linked to the Exemptions table via a link table in a many to many relationship
FOIrequests: PK intFOIRequestsID
Link Table: intFOIRequestsID
intExemptionID
Exemptions Table PK intExemptionID
The main form opens and displays only a combo box of existing Request Numbers.
The user selects a request number and the data for the selected request is displayed.
The main form (tblFOIRequests) has several tabs and one of the tabs has a subform (tblExemptions), if more than one record exists in the sub form i need to update a field (flgExemptionsFlag) in the main record (tblFOIRequests) without user input.
The rest of the main record, which is spread over the other tabs is saved using a save button on the form, giving the user the choice to save or not.
I need to update this one field in the main record using code as i dont want the forms dirty property to be set when this field is updated
intFOIrequestID is the PK of the FOIRequests table (autonumber in design)
Table Name to be updated: FOIRequests
Field Name in table: flgExemptionsFlag (yes/no field in table design)
sub RecordCount
Dim SubFormRecordCountExemp As Long
Dim ExemptionFlag As Variant (not sure if this is correct)
' Subform Exemptions
Set rs = Me.frmExemptionListsubform.Form.RecordsetClone
If Not (rs.EOF) Then
rs.MoveLast
End If
SubFormRecordCountExemp = rs.RecordCount
If SubFormRecordCountExemp > 0 Then
ExemptionFlag = -1
Else
ExemptionFlag = 0
End If
Set rs = Nothing
' Main form
Set rs = Me.RecordsetClone
If Not (rs.EOF) Then
rs.MoveLast
End If
FormRecordCount = rs.RecordCount
DoCmd.RunSQL "UPDATE [tblFOIRequests] SET flgExemptionFlag = '" & ExemptionFlag & "' WHERE tblFOIRequests.intFOIRequestID = '" & [Forms]![frmAmendRequest]![intFOIRequestID] & "'"
End Sub
When running the above code I get the error: data type mismatch in criteria expression:
Thanks in advance
Pat