Selecting a record from a combo bo

G

Guest

Hi All,

I am new to access and vb. I have created a combo box that displays a list
of RGA numbers from a table that I created. When I click on one of the
records, I want to display the entire record. Here is the vb code that I
wrote. I keep getting the message--You entered an expression that has an
invalid reference to the recordset clone property. I do NOT know what to do
to fix it. Here is the code
Private Sub cmbRGAs_Click()

Dim LookFor As String

LookFor = Trim(Me![cmbRGAs])

Me.RecordsetClone.FindFirst "[RGAno] = '" & [LookFor] & "'"
Me.Bookmark = Me.RecordsetClone.Bookmark


End Sub

In advance, thanks for your help.
 
G

Guest

Hi

Put this behind the AfterUpdate of cmbRGAs (your combobox)

Private Sub cmbRGAs _AfterUpdate()
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[RGANo] = " & Str(Me![cmbRGAs ])
Me.Bookmark = rs.Bookmark
End Sub



Hope this helps
 
G

Guest

Hi Wayne,

Thanks for your help. Now I get an error message 'object variable or with
block not set' It points to the vb code Set rs = Me.Recordset.Clone

Thanks,

Randy
Wayne-I-M said:
Hi

Put this behind the AfterUpdate of cmbRGAs (your combobox)

Private Sub cmbRGAs _AfterUpdate()
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[RGANo] = " & Str(Me![cmbRGAs ])
Me.Bookmark = rs.Bookmark
End Sub



Hope this helps

--
Wayne
Manchester, England.
Not an expert will will try to assist where pos.
Enjoy whatever you do.


Randy said:
Hi All,

I am new to access and vb. I have created a combo box that displays a list
of RGA numbers from a table that I created. When I click on one of the
records, I want to display the entire record. Here is the vb code that I
wrote. I keep getting the message--You entered an expression that has an
invalid reference to the recordset clone property. I do NOT know what to do
to fix it. Here is the code
Private Sub cmbRGAs_Click()

Dim LookFor As String

LookFor = Trim(Me![cmbRGAs])

Me.RecordsetClone.FindFirst "[RGAno] = '" & [LookFor] & "'"
Me.Bookmark = Me.RecordsetClone.Bookmark


End Sub

In advance, thanks for your help.
 
G

Guest

Hi Randy

Remove all other find or trim codes from the form the try again (I have just
tried the code I sent and it works). The message you are getting means that
you are trying to either delete or update and as the code I sent only
performs a "find" then may be another problem on the form causing a glitch.

Check this out on the main MS Website and then make sure that you have no
"deleting" code anywhere on your form
http://support.microsoft.com/kb/287485/en-us

Oh and you may be interested in looking at the extremely helpful section on
the ms site regarding the problem that states

"Microsoft has confirmed that this is a problem in the Microsoft products
that are listed at the beginning of this article." Isn't that great :)

If the worst comes to the worst then you may want to delete your combo and
use the wizard to create a new other - select the "find a record ...... -
option on the wizard when running it.

Good luck


--
Wayne
Manchester, England.
Not an expert will try to assist where pos.
Enjoy whatever it is you do.



Randy said:
Hi Wayne,

Thanks for your help. Now I get an error message 'object variable or with
block not set' It points to the vb code Set rs = Me.Recordset.Clone

Thanks,

Randy
Wayne-I-M said:
Hi

Put this behind the AfterUpdate of cmbRGAs (your combobox)

Private Sub cmbRGAs _AfterUpdate()
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[RGANo] = " & Str(Me![cmbRGAs ])
Me.Bookmark = rs.Bookmark
End Sub



Hope this helps

--
Wayne
Manchester, England.
Not an expert will will try to assist where pos.
Enjoy whatever you do.


Randy said:
Hi All,

I am new to access and vb. I have created a combo box that displays a list
of RGA numbers from a table that I created. When I click on one of the
records, I want to display the entire record. Here is the vb code that I
wrote. I keep getting the message--You entered an expression that has an
invalid reference to the recordset clone property. I do NOT know what to do
to fix it. Here is the code
Private Sub cmbRGAs_Click()

Dim LookFor As String

LookFor = Trim(Me![cmbRGAs])

Me.RecordsetClone.FindFirst "[RGAno] = '" & [LookFor] & "'"
Me.Bookmark = Me.RecordsetClone.Bookmark


End Sub

In advance, thanks for your help.
 
J

John Spencer

Some suggested modifications
-- it's RecordSetClone not RecordSet.Clone
-- If RGANo is a text field and not a number field then you need to enclose
it in string delimiters (" or ')
-- I would also make sure a record was found before attempting to move to
the record
-- Finally I would check to make sure something was selected in the combobox

Private Sub cmbRGAs _AfterUpdate()
Dim rs As Object
Set rs = Me.RecordsetClone '<<< note the dropping of the period

If IsNull(Me.cmbRGAs) = False then
rs.FindFirst "[RGANo] = " & Chr(34) & Str(Me![cmbRGAs ]) & Chr(34)
If rs.NoMatch = False then
Me.Bookmark = rs.Bookmark
else
' do something here
End If
End If
End Sub

Wayne-I-M said:
Hi

Put this behind the AfterUpdate of cmbRGAs (your combobox)

Private Sub cmbRGAs _AfterUpdate()
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[RGANo] = " & Str(Me![cmbRGAs ])
Me.Bookmark = rs.Bookmark
End Sub



Hope this helps

--
Wayne
Manchester, England.
Not an expert will will try to assist where pos.
Enjoy whatever you do.


Randy said:
Hi All,

I am new to access and vb. I have created a combo box that displays a
list
of RGA numbers from a table that I created. When I click on one of the
records, I want to display the entire record. Here is the vb code that I
wrote. I keep getting the message--You entered an expression that has an
invalid reference to the recordset clone property. I do NOT know what to
do
to fix it. Here is the code
Private Sub cmbRGAs_Click()

Dim LookFor As String

LookFor = Trim(Me![cmbRGAs])

Me.RecordsetClone.FindFirst "[RGAno] = '" & [LookFor] & "'"
Me.Bookmark = Me.RecordsetClone.Bookmark


End Sub

In advance, thanks for your help.
 
G

Guest

Thanks John

Good point about the full stop.
Also I should not have assumed that RGANo was a number - just that I tend to
put No at the end of my number fields.
Another good point about Me.Bookmark = rs.Bookmark.

I learn loads from this site.

--
Wayne
Manchester, England.
Not an expert will try to assist where pos.
Enjoy whatever it is you do.



John Spencer said:
Some suggested modifications
-- it's RecordSetClone not RecordSet.Clone
-- If RGANo is a text field and not a number field then you need to enclose
it in string delimiters (" or ')
-- I would also make sure a record was found before attempting to move to
the record
-- Finally I would check to make sure something was selected in the combobox

Private Sub cmbRGAs _AfterUpdate()
Dim rs As Object
Set rs = Me.RecordsetClone '<<< note the dropping of the period

If IsNull(Me.cmbRGAs) = False then
rs.FindFirst "[RGANo] = " & Chr(34) & Str(Me![cmbRGAs ]) & Chr(34)
If rs.NoMatch = False then
Me.Bookmark = rs.Bookmark
else
' do something here
End If
End If
End Sub

Wayne-I-M said:
Hi

Put this behind the AfterUpdate of cmbRGAs (your combobox)

Private Sub cmbRGAs _AfterUpdate()
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[RGANo] = " & Str(Me![cmbRGAs ])
Me.Bookmark = rs.Bookmark
End Sub



Hope this helps

--
Wayne
Manchester, England.
Not an expert will will try to assist where pos.
Enjoy whatever you do.


Randy said:
Hi All,

I am new to access and vb. I have created a combo box that displays a
list
of RGA numbers from a table that I created. When I click on one of the
records, I want to display the entire record. Here is the vb code that I
wrote. I keep getting the message--You entered an expression that has an
invalid reference to the recordset clone property. I do NOT know what to
do
to fix it. Here is the code
Private Sub cmbRGAs_Click()

Dim LookFor As String

LookFor = Trim(Me![cmbRGAs])

Me.RecordsetClone.FindFirst "[RGAno] = '" & [LookFor] & "'"
Me.Bookmark = Me.RecordsetClone.Bookmark


End Sub

In advance, thanks for your help.
 

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