Newbie seeks help with Select Statement 
Author Message
 Newbie seeks help with Select Statement

Am trying to edit records with DAO, and keep getting a type mismatch error
when using the following code:

Set rs = db.OpenRecordset("SELECT * FROM tblOrderItems WHERE [OrderItemID] =
'" & Me![cboItem1] & "'", dbOpenDynaset)

When I try this alternative, I get an error indicating Too few paramters.
Expected 1:

Set rs = db.OpenRecordset("SELECT * FROM tblOrderItems WHERE [OrderItemID] =
Me![cboItem1]", dbOpenDynaset)

I am sure this will only take a second, so thank you in advance.

Regards,

Alex



Fri, 23 May 2003 03:00:00 GMT  
 Newbie seeks help with Select Statement

I assume OrderItemID is a number data type? If so, try the first option,
sans quotes around the id value.

--
MichKa

a new book on internationalization in VB at
http://www.i18nWithVB.com/



Quote:
> Am trying to edit records with DAO, and keep getting a type mismatch error
> when using the following code:

> Set rs = db.OpenRecordset("SELECT * FROM tblOrderItems WHERE [OrderItemID]
=
> '" & Me![cboItem1] & "'", dbOpenDynaset)

> When I try this alternative, I get an error indicating Too few paramters.
> Expected 1:

> Set rs = db.OpenRecordset("SELECT * FROM tblOrderItems WHERE [OrderItemID]
=
> Me![cboItem1]", dbOpenDynaset)

> I am sure this will only take a second, so thank you in advance.

> Regards,

> Alex



Fri, 23 May 2003 03:00:00 GMT  
 Newbie seeks help with Select Statement
What are the types in your [cboItem1]
If it's dates then use: WHERE [OrderItemID] =  #" & Me![cboItem1] & "#;"
'Note must be valid SQL date
If it's strings then use: WHERE [OrderItemID] =  '" & Me![cboItem1] & "';"
If it's numbers then use: WHERE [OrderItemID] =  " & Me![cboItem1] & ";"
If it's a Null you will have to solve that issue as well.

--
Regards Hans-Chr. Francke
www.master-office.com



Quote:
> Am trying to edit records with DAO, and keep getting a type mismatch error
> when using the following code:

> Set rs = db.OpenRecordset("SELECT * FROM tblOrderItems WHERE [OrderItemID]
=
> '" & Me![cboItem1] & "'", dbOpenDynaset)

> When I try this alternative, I get an error indicating Too few paramters.
> Expected 1:

> Set rs = db.OpenRecordset("SELECT * FROM tblOrderItems WHERE [OrderItemID]
=
> Me![cboItem1]", dbOpenDynaset)

> I am sure this will only take a second, so thank you in advance.

> Regards,

> Alex



Fri, 23 May 2003 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. newbie seeking help on setting security

2. Newbie seeks help with form-based DAO insert

3. Newbie seeks help with custom action

4. Newbie seeking help with DataControl or database

5. Newbie seeks help with strings and ini files

6. Newbie Seeks Help - Finding the CDROM Drive

7. Newbie seeks help.

8. Newbie seeks help with MS Access

9. Help: Newbie seeks starting point

10. Newbie seeking help with DataControl or database

11. Newbie seeking help with DataControl or database

12. How to select the current record only with SELECT statement

 

 
Powered by phpBB® Forum Software