Hi all,
Sorry to post again...I need some advice! I have made a function to check a query (based on a LINKED table) to see if a value exists.
I am getting the 'Data type mismatch' error when running the code -
Private Sub cmdFind_Click()
Dim ChqString As String
Dim Acc As String
Dim BSB As String
Dim Chq As String
Dim qryAmount As Currency
Dim qryStatus As String
Dim qryRec As Date
Acc = Me.txtAccNo.Value
BSB = Me.txtBSBNo.Value
Chq = Me.txtChqNo.Value
ChqString = Chq & BSB & Acc
Me.txtchqstring.Value = ChqString
If Me.txtchqstring.Value = DLookup("Number", "querypayment") Then
qryAmount = DLookup("Amount", "querypayment", "[Number]=" & Me.txtchqstring.Value)
qryStatus = DLookup("Status", "querypayment", "[Number]=" & Me.txtchqstring.Value)
qryRec = DLookup("Received", "querypayment", "[Number]=" & Me.txtchqstring.Value)
MsgBox "etc......."
Else
MsgBox "Records do not indicate this cheque was received"
End If
End Sub
The error occurs when trying to do the DLOOKUP for 'qryAmount'.
I have checked the table design for the table the query is based on - and the field types indeed match up to those I have declared.
ie Amount is Currency
Received is Date/Time
Status is Text
I have also tried declaring them as String/Integer/Long etc - with the same error always occurring.
Have I taken the wrong approach with my code? Or is there perhaps something else I have overlooked?
Thanks again
Rob
Sorry to post again...I need some advice! I have made a function to check a query (based on a LINKED table) to see if a value exists.
I am getting the 'Data type mismatch' error when running the code -
Private Sub cmdFind_Click()
Dim ChqString As String
Dim Acc As String
Dim BSB As String
Dim Chq As String
Dim qryAmount As Currency
Dim qryStatus As String
Dim qryRec As Date
Acc = Me.txtAccNo.Value
BSB = Me.txtBSBNo.Value
Chq = Me.txtChqNo.Value
ChqString = Chq & BSB & Acc
Me.txtchqstring.Value = ChqString
If Me.txtchqstring.Value = DLookup("Number", "querypayment") Then
qryAmount = DLookup("Amount", "querypayment", "[Number]=" & Me.txtchqstring.Value)
qryStatus = DLookup("Status", "querypayment", "[Number]=" & Me.txtchqstring.Value)
qryRec = DLookup("Received", "querypayment", "[Number]=" & Me.txtchqstring.Value)
MsgBox "etc......."
Else
MsgBox "Records do not indicate this cheque was received"
End If
End Sub
The error occurs when trying to do the DLOOKUP for 'qryAmount'.
I have checked the table design for the table the query is based on - and the field types indeed match up to those I have declared.
ie Amount is Currency
Received is Date/Time
Status is Text
I have also tried declaring them as String/Integer/Long etc - with the same error always occurring.
Have I taken the wrong approach with my code? Or is there perhaps something else I have overlooked?
Thanks again
Rob