combo box to fill form (1 Viewer)

smartslingaro

Registered User.
Local time
Today, 09:50
Joined
Aug 23, 2019
Messages
17
I need a search bar on my form that will bring record in the form from the search bar. I don't code much, but watched a good video that seems to do what I want, and I followed it piece by piece, but keep getting an error :

This error occurs when an event has failed to run because the location of the logic for the event cannot be evaluated. For example, if the OnOpen property of a form is set to =[Field], this error occurs because a macro or event name is expected to run when the event occurs.

This is the code I used.
Private Sub cbogotorecord_AfterUpdate()
Dim rst As Object
Set rst = Me.RecordsetClone
rst.FindFirst "[Student ID]=" & Me.cbogotorecord.Value
Me.Bookmark = rst.Bookmark
End Sub

what am i doing wrong. ?
 
Last edited:

theDBguy

I’m here to help
Staff member
Local time
Today, 09:50
Joined
Oct 29, 2018
Messages
21,467
Hi. I don't see anything wrong with that code other than you're not clearing the variable at the end. Since that code is in the AfterUpdate event of the combobox, and if you're getting an error about the Form's Open event, then that code might not have anything to do with the error you're having. Can you post a sample copy of your db with test data for testing?
 

smartslingaro

Registered User.
Local time
Today, 09:50
Joined
Aug 23, 2019
Messages
17
here is a copy of test... oops telling me it is too big? ok think i did it, I made it smaller and left out most of it. but this is the part I need first. should be simple, no?
 

Attachments

  • Database3.accdb
    1.2 MB · Views: 83
Last edited:

theDBguy

I’m here to help
Staff member
Local time
Today, 09:50
Joined
Oct 29, 2018
Messages
21,467
here is a copy of test... oops telling me it is too big? ok think i did it, I made it smaller and left out most of it. but this is the part I need first. should be simple, no?
Hi. Thanks! I'm not getting any errors with your form. Can you provide the steps to duplicate the problem?
 

smartslingaro

Registered User.
Local time
Today, 09:50
Joined
Aug 23, 2019
Messages
17
When I click on the combo box for a name I get the error and it doesn't fill my form. Working on getting you screen shot.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 09:50
Joined
Oct 29, 2018
Messages
21,467
your right, wonder why it works there on test db
When you created the test db, you must have taken out a few things. Try putting them back in one at a time until you find which one is causing the problem and then let us know what it is, so we can help you fix it.
 

smartslingaro

Registered User.
Local time
Today, 09:50
Joined
Aug 23, 2019
Messages
17
thank you for the exercise of copying the db. one of them has all the data, but not the other forms/queries/macros. probably a macro screwing it up., and they don't really seem to work now that i've copied them into newer db. Is that common? normal?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 09:50
Joined
Oct 29, 2018
Messages
21,467
thank you for the exercise of copying the db. one of them has all the data, but not the other forms/queries/macros. probably a macro screwing it up., and they don't really seem to work now that i've copied them into newer db. Is that common? normal?
So, putting it back together one piece at a time didn't give you an idea what made it stop working again?
 

smartslingaro

Registered User.
Local time
Today, 09:50
Joined
Aug 23, 2019
Messages
17
I have been putting them back one by one.. Haven't found the issue, but I think it was a macro somewhere. I had tons of crap in there as I am still in the process of building. It was good to strip it down. Thank you.

Before I go to much further, I need to figure how to open a report filtered on the current record.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 09:50
Joined
Oct 29, 2018
Messages
21,467
I have been putting them back one by one.. Haven't found the issue, but I think it was a macro somewhere. I had tons of crap in there as I am still in the process of building. It was good to strip it down. Thank you.

Before I go to much further, I need to figure how to open a report filtered on the current record.
You can use the WhereCondition argument of the OpenReport method. For example:
Code:
DoCmd.OpenReport "ReportName', acViewPreview, , "ID=" & Me.ID
 

Users who are viewing this thread

Top Bottom