|
 |
access thread: FW: AutoNumber as Variable and use as Criteria
Message #1 by "George Oro" <george@c...> on Thu, 27 Jun 2002 12:56:06 +0400
|
|
-----Original Message-----
From: George Oro [mailto:george@c...]
Sent: Thursday, June 27, 2002 11:40 AM
To: Access Help
Subject: AutoNumber as Variable and use as Criteria
Hi Guys,
I think this is very simple but I cannot figure it out.
I created this code as a test to use the AutoNumber as a Criteria and view the company name. I used the CustomerID (AutoNumber) of
the current form as my criteria. Once I click the cmdAutoNumber just to view the company name, I'm getting this error "Too few
parameters. Expected 1."
Private Sub cmdAutoNumber_Click()
On Error GoTo Err_cmdAutoNumber_Click
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim lngCurrentID as Long
lngCurrentID=Me.CustomerID
Set db = CurrentDb
Set rs = db.OpenRecordset("SELECT Customers.CustomerID, Customers.CompanyName FROM Customers WHERE Customers.CustomerID
lngCurrentID;")
MsgBox "Company Name: " & rs("CompanyName")
Exit_cmdAutoNumber_Click:
Exit Sub
Err_cmdAutoNumber_Click:
MsgBox Err.Description
Resume Exit_cmdAutoNumber_Click
End Sub
Can anyone help me pls...
Cheers,
George
Message #2 by braxis@b... on Thu, 27 Jun 2002 10:07:06 +0100 (BST)
|
|
Hi George
You've put your variable (lngCurrentID) in the string.
Change:
"SELECT Customers.CustomerID, Customers.CompanyName FROM Customers WHERE Customers.CustomerID= lngCurrentID;"
To:
"SELECT Customers.CustomerID, Customers.CompanyName FROM Customers WHERE Customers.CustomerID=" & lngCurrentID
> from: George Oro <george@c...>
> date: Thu, 27 Jun 2002 09:56:06
> to: access@p...
> subject: Re: [access] FW: AutoNumber as Variable and use as Criteria
>
>
>
> -----Original Message-----
> From: George Oro [mailto:george@c...]
> Sent: Thursday, June 27, 2002 11:40 AM
> To: Access Help
> Subject: AutoNumber as Variable and use as Criteria
>
>
> Hi Guys,
>
> I think this is very simple but I cannot figure it out.
>
> I created this code as a test to use the AutoNumber as a Criteria and view the company name. I used the CustomerID (AutoNumber)
of
> the current form as my criteria. Once I click the cmdAutoNumber just to view the company name, I'm getting this error "Too few
> parameters. Expected 1."
>
>
> Private Sub cmdAutoNumber_Click()
> On Error GoTo Err_cmdAutoNumber_Click
>
> Dim db As DAO.Database
> Dim rs As DAO.Recordset
> Dim lngCurrentID as Long
> lngCurrentID=Me.CustomerID
>
> Set db = CurrentDb
> Set rs = db.OpenRecordset("SELECT Customers.CustomerID, Customers.CompanyName FROM Customers WHERE Customers.CustomerID
> lngCurrentID;")
>
> MsgBox "Company Name: " & rs("CompanyName")
>
>
> Exit_cmdAutoNumber_Click:
> Exit Sub
>
> Err_cmdAutoNumber_Click:
> MsgBox Err.Description
> Resume Exit_cmdAutoNumber_Click
>
> End Sub
>
>
> Can anyone help me pls...
>
>
> Cheers,
> George
>
>
Message #3 by "George Oro" <george@c...> on Thu, 27 Jun 2002 13:14:06 +0400
|
|
Hi,
Many, many Thanks, its working!
Cheers
George ^_^
-----Original Message-----
From: braxis@b... [mailto:braxis@b...]
Sent: Thursday, June 27, 2002 1:07 PM
To: Access
Subject: [access] Re: FW: AutoNumber as Variable and use as Criteria
Hi George
You've put your variable (lngCurrentID) in the string.
Change:
"SELECT Customers.CustomerID, Customers.CompanyName FROM Customers WHERE Customers.CustomerID= lngCurrentID;"
To:
"SELECT Customers.CustomerID, Customers.CompanyName FROM Customers WHERE Customers.CustomerID=" & lngCurrentID
> from: George Oro <george@c...>
> date: Thu, 27 Jun 2002 09:56:06
> to: access@p...
> subject: Re: [access] FW: AutoNumber as Variable and use as Criteria
>
>
>
> -----Original Message-----
> From: George Oro [mailto:george@c...]
> Sent: Thursday, June 27, 2002 11:40 AM
> To: Access Help
> Subject: AutoNumber as Variable and use as Criteria
>
>
> Hi Guys,
>
> I think this is very simple but I cannot figure it out.
>
> I created this code as a test to use the AutoNumber as a Criteria and view the company name. I used the CustomerID (AutoNumber)
of
> the current form as my criteria. Once I click the cmdAutoNumber just to view the company name, I'm getting this error "Too few
> parameters. Expected 1."
>
>
> Private Sub cmdAutoNumber_Click()
> On Error GoTo Err_cmdAutoNumber_Click
>
> Dim db As DAO.Database
> Dim rs As DAO.Recordset
> Dim lngCurrentID as Long
> lngCurrentID=Me.CustomerID
>
> Set db = CurrentDb
> Set rs = db.OpenRecordset("SELECT Customers.CustomerID, Customers.CompanyName FROM Customers WHERE Customers.CustomerID
> lngCurrentID;")
>
> MsgBox "Company Name: " & rs("CompanyName")
>
>
> Exit_cmdAutoNumber_Click:
> Exit Sub
>
> Err_cmdAutoNumber_Click:
> MsgBox Err.Description
> Resume Exit_cmdAutoNumber_Click
>
> End Sub
>
>
> Can anyone help me pls...
>
>
> Cheers,
> George
>
>
|
|
 |