Help!!! Please, Type Mismatch error 13 
Author Message
 Help!!! Please, Type Mismatch error 13

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?

--
   \\\|///  
 \\  ~ ~  //

oOOo (_) oOOo



Sun, 09 Jan 2000 03:00:00 GMT  
 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



Sun, 09 Jan 2000 03:00:00 GMT  
 Help!!! Please, Type Mismatch error 13

Since localData is a long, it should not be in quotes in the sql statement.
Change this line:

sSQL = sSQL + " WHERE " & FLD_Cust_Number & " = '" & localLData & "';"

to:

sSQL = sSQL + " WHERE " & FLD_Cust_Number & " =  " & localLData & ";"

BTW: You don't need the semicolon....

  >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?
  >
  >--
  >   \\\|///  
  > \\  ~ ~  //

  >oOOo (_) oOOo

  >



Sun, 09 Jan 2000 03:00:00 GMT  
 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

> 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

Single Quote can be double quoted, so you can try this:

Quote:
> sSQL="SELECT * From " & TBL_Customers
> sSQL=sSQL & " Where "& FLD_Cust_Number & "= '" & localLData & "'" & ....

I think it's clearer.

Bye!
Xavi.



Mon, 10 Jan 2000 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. HELP --- Adding ListItem to ListView always returns Error 13 - Type Mismatch

2. Worked fine yesterday, today I get Error 13 Type Mismatch errors

3. Error 13: Type Mismatch error

4. Type Mismatch Run-Time error 13

5. Type Mismatch Error 13

6. type mismatch error '13'????

7. Using CurrentDB() receives Type Mismatch Error 13

8. Type mismatch, run-time error #13

9. type 13 mismatch error

10. ACC2000:Run Time Error '13': Type Mismatch

11. Invalid Reference (Error 13 - Type Mismatch)

12. Run -time error '13' Type Mismatch

 

 
Powered by phpBB® Forum Software