Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

update form with combobox selection 1

Status
Not open for further replies.

Duane8889

Programmer
Dec 14, 2001
46
0
0
US
Hello
I'm trying to update my contacts form with a combobox. I'm using Access 2k. I tried this code:
Code:
private sub cboName_AfterUpdate()
  me.recordsetclone.FindFirst "[ID] = " & Me![cboName]
  me.bookmark = me.recordsetclone.bookmark
end sub

private sub Form_Current()
  cboName = ID
end sub
cboName is the combobox. But it doesn't even click properly I mean you click and it opens then after choosing an item it just hangs there.

in cboName properties I have it as unbound
table/query for rowsourcetype
SELECT DISTINCTROW tblContacts.ID, [LastName] & ", " & [FirstName] AS Expr1 FROM tblContacts ORDER BY [LastName] & ", " & [FirstName]; for the Row Source
Column Count is 2
Width is 0";1.416"

not sure what else is pertinent info
please help I worked too long on this to admit.

Duane

 
If you need just find that record what you have selected from the combo then you can create another combo through the wizard and choose the third option from the first screen.
or you could change the code like below
[tt]
private sub cboName_AfterUpdate()
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[ID] = " & Str(Nz(Me![cboName], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
end sub
[/tt]
Also I don't think the code OnCurrent Event is necessary there.
If you trying to do something else then pls tell us

________________________________________________________________________
Zameer Abdulla
Visit Me
A sweater is usually put on a child when the parent feels chilly.
 
thanks Zameer Abdulla
I used your code:
Code:
Private Sub cboName_AfterUpdate()
Dim rs As Object

  Set rs = Me.Recordset.Clone
  rs.FindFirst "[ID] = " & Str(Nz(Me![cboName], 0))  
  If Not rs.EOF Then Me.Bookmark = rs.Bookmark
end sub
but I'm still getting the same results. I also commented out the code:
Code:
private sub Form_Current()
  cboName = ID
end sub
it was just included when I copied the code from another Access pgm.

I tried using the wizard as you suggested but the combobox still drops down then freezes. Bizarre.

regards,
Duane
 
Try Compact & Repair database from the Tools Menu

________________________________________________________________________
Zameer Abdulla
Visit Me
A sweater is usually put on a child when the parent feels chilly.
 
I tried the compact and repair and it's still the same. I hope I did it right it went in a blink of an eye. But it's a small db.

thanks for trying!
Duane
 
Can you try to create another "form" and see what is the result.

________________________________________________________________________
Zameer Abdulla
Visit Me
A sweater is usually put on a child when the parent feels chilly.
 
I created another form in design view and the cbo box works. Now I just need to get the other boxes etc to work.

thanks 'aplenty

Duane
 
Your form was corrupted...

________________________________________________________________________
Zameer Abdulla
Visit Me
A sweater is usually put on a child when the parent feels chilly.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top