Kamis, 25 Februari 2021

Re: [MSAccessProfessionals] Type Mismatch Run-time error ...Tired of this issue...

You have extra quotes on either side of the AND. Do you have Option Explicit in your module header? Does your code compile?

Is the OTID data type text or numeric? This code should work with numeric.

strSQL = "DELETE * FROM T_EmpOTFooter WHERE OTID = " & Forms!F_EmpOTHeader!OTID & " And CheckRightOT = 0; " 

I would also add a line
debug.print strSQL

This will print the value of strSQL in the immediate/debug window (press Ctrl+G to view).

Regards,
Duane


From: SAYYED ASHFAQUE HUSSAIN via groups.io <ashfaque_online=yahoo.com@groups.io>

Hi,

My BE is on SQL Server whereas FE in off course in Access. I have a header form and a sub-form added into. This is you can say one-to-many record register. It is register to record dept wize overtime of the employee.

I have below code thru which I want to delete those record which have UNCHECKED (Bit type field on server).

Private Sub OMApproval_Click()  Dim Msg As String, Style As Integer, Title As String, Response As Integer  Dim strSQL As String  Msg = "You are about to delete all unchecked entries from sub-form."  Style = vbOKCancel + vbQuestion + vbDefaultButton2  Title = "Continue?"  Response = MsgBox(Msg, Style, Title)  If Response = vbOK Then  strSQL = "DELETE * FROM T_EmpOTFooter WHERE CheckRightOT.value = false " And " OTID = " & Forms!F_EmpOTHeader!OTID  CurrentDb.Execute dbFailOnError  Me!SF_EmpOTFooter.Form.Requery  Else  MsgBox "No record deleted", vbOKOnly, "Info"  End If  End Sub

But the problem is it always producing above error.
With some of people suggestion I changed to StrSQL line as follows but still same error.
Please note that OMApproval is checkmark on my header form.
strSQL = "DELETE * FROM T_EmpOTFooter WHERE OTID = " & Forms!F_EmpOTHeader!OTID & " And CheckRightOT = 0; " 

Still same....please advise.
Thank you in Advance...
_
_._,_._,_

Tidak ada komentar:

Posting Komentar