Opening form from command button (1 Viewer)

djenkins1973

New member
Local time
Today, 14:25
Joined
Dec 3, 2019
Messages
6
Hi

I'm baffled!

I'm putting together a very simple (initially 1 table, 3 forms, 3 queries, 1 report) database and I'm struggling with something.

I've got all my functionality pretty much as I want it but I'm now trying to create a switchboard.


My main form is a search form that has a subform with data from a query. I have 2 unbound text boxes on the form which have code- Forms(“frmName”).Controls(“frmNameSub“).Form.Requery - in the afterupdate event to requery the subform.

If I open the form from the navigation pane it works but if I open it from a command button I get runtime-error 438 every time I enter text in either text box

If I debug when I get the error I can see "frmName"=empty if I hover over it.

any help greatly appreciated
 
Last edited:

theDBguy

I’m here to help
Staff member
Local time
Today, 07:25
Joined
Oct 29, 2018
Messages
21,357
Hi. Can you post a sample copy of your db with test data?
 

djenkins1973

New member
Local time
Today, 14:25
Joined
Dec 3, 2019
Messages
6
Here you go

Thanks!
 

Attachments

  • djenkins123.zip
    552.3 KB · Views: 139

djenkins1973

New member
Local time
Today, 14:25
Joined
Dec 3, 2019
Messages
6
Hi. Thanks but no that didn't work.

For some reason the search boxes now don't work even when launching from the navigation pane. I don't get the runtime error but any input in those results in no returned data in the subform.
 

Gasman

Enthusiastic Amateur
Local time
Today, 14:25
Joined
Sep 21, 2011
Messages
14,044
I changed it to

Code:
Option Compare Database
Private Sub txtManufacturerInput_AfterUpdate()
'Forms(“frmVehicleList”).Controls(“frmVehicleListSub“).Form.Requery
Me.qryVehicle_subform.Form.Requery
End Sub
Private Sub txtModelInput_AfterUpdate()
'Forms(“frmVehicleList”).Controls(“frmVehicleListSub“).Form.Requery
Me.qryVehicle_subform.Form.Requery
End Sub

That works via the switchboard button, both of them?

HTH
 
Last edited:

djenkins1973

New member
Local time
Today, 14:25
Joined
Dec 3, 2019
Messages
6
Thank you!

That works.... I've been playing too and

DoCmd.Requery (frmVehicleListSub)

also works
 

theDBguy

I’m here to help
Staff member
Local time
Today, 07:25
Joined
Oct 29, 2018
Messages
21,357
Hi. Glad to hear you got it sorted out. Good luck with your project.


Thanks for the assist, Gasman!
 

Users who are viewing this thread

Top Bottom