
Help!!! Please, Type Mismatch error 13
Quote:
> please help me out with this one.
> Private Sub Form_Load()
> Dim localLData As Long
> Dim rsData As String
> localLData = IIf(IsNull(lData), localLData, lData)
> 'MsgBox ("global = " & lData)
> 'MsgBox ("local = " & localLData)
> sSQL = "SELECT * FROM " & TBL_Customers
> sSQL = sSQL + " WHERE " & FLD_Cust_Number & " = '" & localLData & "';"
> 'MsgBox ("sSQL = " & sSQL)
> 'runtime error 13
> 'type mismatch
> Set rsCust1 = dbDallas.OpenRecordset(sSQL)
> End Sub
> lData is a global Long
> dbDallas is a global name and path for an access mdb
> TBL_Customers is a global name for an access table Customers
> FLD_Cust_Number is a global long field in the Customers table
> the set rsCust1 = dbdallas.OpenRecordset(sSQL) works every where else why
> not here? is it because it is has a long feild in it?
Just a thought, as far as I can tell you have not enclosed the variable
localLdata in the quotes as VB is looking for.
Try this;
sSQL="SELECT * From " & TBL_Customers
sSQL=sSQL & " Where "& FLD_Cust_Number & "=" & CHR(34) & localLData &
CHR(34) & ........
apparently VB gets confused if you put a variable name in a string, it
must be enclosed in single quotes which is the chr(34). I think that you
can also use double " and get the same effect.
Cheers