record set trouble

  • Thread starter matt donker via AccessMonster.com
  • Start date
M

matt donker via AccessMonster.com

Hey guys

My goal here is to have the user select what they want in the cascading
combo boxes on one form. Once a command button is pressed another form is
opened using the information from the combo bo box's to set its record
source to the match the information in the combo box. I used a simple
query method but i get an object required everytime i run it. I am
guessing that i went about this the wrong way or that there is a simple
error. Can somesomone please help me.

My code for the first form is as follows:

Private Sub cmdContinue_Click()
'Make variable to hold query
Dim str3 As String

str3 = "SELECT * FROM [tblFixtures] WHERE [Part Used For] = Forms!
[frmSelect]![cmbPartUsedFor] & [Fixture #] = Forms![frmSelect]![cmbFixture#]
"

'Set the row source of the info form to the query

Set Forms![frmInfo].Recordset = str3

'Open the form
DoCmd.OpenForm "frmInfo"
 
G

Guest

Perhaps something like this will accomplish your goal:


str3 = "SELECT * FROM [tblFixtures] WHERE [Part Used For] = Forms! _
[frmSelect]![cmbPartUsedFor] & [Fixture #] =
Forms![frmSelect]![cmbFixture#] _
"
'Open the form
DoCmd.OpenForm "frmInfo"

'Set the row source of the info form to the query
Set Forms![frmInfo].Recordset = CurrentDb().OpenRecordset(str3)

I believe that you must open the form THEN set its recordset property.
Also, the above cose is "Air" (not tested). I have used similar code -- if
the above does not work I reccomend creating a recordset variable in the
first form like this:

Dim rst as Recordset
Set rst = CurrentDb().OpenRecordset(str3)

'Open the form
DoCmd.OpenForm "frmInfo"

'Set the row source of the info form to the query
Set Forms![frmInfo].Recordset = rst

HTH!
Hey guys

My goal here is to have the user select what they want in the cascading
combo boxes on one form. Once a command button is pressed another form is
opened using the information from the combo bo box's to set its record
source to the match the information in the combo box. I used a simple
query method but i get an object required everytime i run it. I am
guessing that i went about this the wrong way or that there is a simple
error. Can somesomone please help me.

My code for the first form is as follows:

Private Sub cmdContinue_Click()
'Make variable to hold query
Dim str3 As String

str3 = "SELECT * FROM [tblFixtures] WHERE [Part Used For] = Forms!
[frmSelect]![cmbPartUsedFor] & [Fixture #] = Forms![frmSelect]![cmbFixture#]
"

'Set the row source of the info form to the query

Set Forms![frmInfo].Recordset = str3

'Open the form
DoCmd.OpenForm "frmInfo"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top