Unbound Textbox with Parameter Query

  • Thread starter Thread starter mindlike
  • Start date Start date
M

mindlike

I have an unbound textbox "txtTicker" in a form where I would like to enter a
ticker ie. "IBM" to pull a rating "SchwabGrade" from a table "Model Data"
into another textbox "txtSER". The table is in L:"\Member\EventData.mdb"

I'm using this code below to try and do it: I continue to get the error:
Run time error 3061. Too few parameters. Expected 1. Seen lots of commentary
on the web about this error, but none that address my situation. Could
someone please help.

Set dbs = OpenDatabase("L:\Member\EventData.mdb")
Set rst = dbs.OpenRecordset("PARAMETERS " & Me.txtTicker & " Text(255);
SELECT [Model Data].SchwabGrade FROM [Model Data] WHERE ((([Model
Data].CompanySymbol) = " & Me.txtTicker & "))")
tickerField = rst
Me.txtSER = tickerField
dbs.Close

thanks in advance for any help
 
I have an unbound textbox "txtTicker" in a form where I would like to enter a
ticker ie. "IBM" to pull a rating  "SchwabGrade" from a table "Model Data"
into another textbox "txtSER".  The table is in L:"\Member\EventData.mdb"

I'm using this code below to try and do it:  I continue to get the error:  
Run time error 3061.  Too few parameters. Expected 1. Seen lots of commentary
on the web about this error, but none that address my situation.  Could
someone please help.

Set dbs = OpenDatabase("L:\Member\EventData.mdb")
Set rst = dbs.OpenRecordset("PARAMETERS " & Me.txtTicker & " Text(255);
SELECT [Model Data].SchwabGrade FROM [Model Data] WHERE ((([Model
Data].CompanySymbol) = " & Me.txtTicker & "))")
tickerField = rst
Me.txtSER = tickerField
dbs.Close

thanks in advance for any help

Air code bellow, if there are errors you could probably solve it
easily. You need to define Parameter, like:

Dim qdf As DAO.QueryDef
Dim rst As DAO.Recordset
Dim dbs As DAO.Database
Set dbs = OpenDatabase("L:\Member\EventData.mdb")
Set qdf = dbs.QueryDefs("PARAMETERS " & Me.txtTicker & " Text(255);
SELECT [Model Data].SchwabGrade FROM [Model Data] WHERE ((([Model
Data].CompanySymbol) = " & Me.txtTicker & "))")
qdf.Parameters(0) = Me.txtTicker
Set rst = qdf.OpenRecordset
tickerField = rst
Me.txtSER = tickerField
dbs.Close

There are many posts about "Too few parameters" error around, so you
can find similar answers.

Regards,
Branislav Mihaljev
Microsoft Access MVP
 
Thanks Branislov,

Modified code and ran. Execution is stopping on
Set qdf = dbs.QueryDefs("PARAMETERS " & Me.txtTicker & " Text(255);
SELECT [Model Data].SchwabGrade FROM [Model Data] WHERE ((([Model
Data].CompanySymbol) = " & Me.txtTicker & "))")

producing error 3265: Item not found in collection. Any ideas on what in
the collection is missing? A query name? Syntax appears fine in the line.

Michael

--
Michael


I have an unbound textbox "txtTicker" in a form where I would like to enter a
ticker ie. "IBM" to pull a rating "SchwabGrade" from a table "Model Data"
into another textbox "txtSER". The table is in L:"\Member\EventData.mdb"

I'm using this code below to try and do it: I continue to get the error:
Run time error 3061. Too few parameters. Expected 1. Seen lots of commentary
on the web about this error, but none that address my situation. Could
someone please help.

Set dbs = OpenDatabase("L:\Member\EventData.mdb")
Set rst = dbs.OpenRecordset("PARAMETERS " & Me.txtTicker & " Text(255);
SELECT [Model Data].SchwabGrade FROM [Model Data] WHERE ((([Model
Data].CompanySymbol) = " & Me.txtTicker & "))")
tickerField = rst
Me.txtSER = tickerField
dbs.Close

thanks in advance for any help

Air code bellow, if there are errors you could probably solve it
easily. You need to define Parameter, like:

Dim qdf As DAO.QueryDef
Dim rst As DAO.Recordset
Dim dbs As DAO.Database
Set dbs = OpenDatabase("L:\Member\EventData.mdb")
Set qdf = dbs.QueryDefs("PARAMETERS " & Me.txtTicker & " Text(255);
SELECT [Model Data].SchwabGrade FROM [Model Data] WHERE ((([Model
Data].CompanySymbol) = " & Me.txtTicker & "))")
qdf.Parameters(0) = Me.txtTicker
Set rst = qdf.OpenRecordset
tickerField = rst
Me.txtSER = tickerField
dbs.Close

There are many posts about "Too few parameters" error around, so you
can find similar answers.

Regards,
Branislav Mihaljev
Microsoft Access MVP
 
Ok...got a solution. This coding worked after I created a Query named
"qdf_FindTicker" in the L:\Member\EventData.mdb database. Thanks for
help...nice have this over

Private Sub txtTicker_BeforeUpdate(Cancel As Integer)

Dim qdf As DAO.QueryDef
Dim rst As DAO.Recordset
Dim dbs As DAO.Database

Set dbs = OpenDatabase("L:\Member\EventData.mdb")
Set qdf = dbs.QueryDefs("qdf_FindTicker")
qdf.Parameters("Ticker") = Me.txtTicker
Set rst = qdf.OpenRecordset
tickerField = rst.Fields("SchwabGrade").Value
Me.txtSER = tickerField
dbs.Close

End Sub

--
Michael


mindlike said:
Thanks Branislov,

Modified code and ran. Execution is stopping on
Set qdf = dbs.QueryDefs("PARAMETERS " & Me.txtTicker & " Text(255);
SELECT [Model Data].SchwabGrade FROM [Model Data] WHERE ((([Model
Data].CompanySymbol) = " & Me.txtTicker & "))")

producing error 3265: Item not found in collection. Any ideas on what in
the collection is missing? A query name? Syntax appears fine in the line.

Michael

--
Michael


I have an unbound textbox "txtTicker" in a form where I would like to enter a
ticker ie. "IBM" to pull a rating "SchwabGrade" from a table "Model Data"
into another textbox "txtSER". The table is in L:"\Member\EventData.mdb"

I'm using this code below to try and do it: I continue to get the error:
Run time error 3061. Too few parameters. Expected 1. Seen lots of commentary
on the web about this error, but none that address my situation. Could
someone please help.

Set dbs = OpenDatabase("L:\Member\EventData.mdb")
Set rst = dbs.OpenRecordset("PARAMETERS " & Me.txtTicker & " Text(255);
SELECT [Model Data].SchwabGrade FROM [Model Data] WHERE ((([Model
Data].CompanySymbol) = " & Me.txtTicker & "))")
tickerField = rst
Me.txtSER = tickerField
dbs.Close

thanks in advance for any help

Air code bellow, if there are errors you could probably solve it
easily. You need to define Parameter, like:

Dim qdf As DAO.QueryDef
Dim rst As DAO.Recordset
Dim dbs As DAO.Database
Set dbs = OpenDatabase("L:\Member\EventData.mdb")
Set qdf = dbs.QueryDefs("PARAMETERS " & Me.txtTicker & " Text(255);
SELECT [Model Data].SchwabGrade FROM [Model Data] WHERE ((([Model
Data].CompanySymbol) = " & Me.txtTicker & "))")
qdf.Parameters(0) = Me.txtTicker
Set rst = qdf.OpenRecordset
tickerField = rst
Me.txtSER = tickerField
dbs.Close

There are many posts about "Too few parameters" error around, so you
can find similar answers.

Regards,
Branislav Mihaljev
Microsoft Access MVP
 
Back
Top