DoCmd OpenForm with Form and Subform

ShovelinFishHeads

Registered User.
Local time
Today, 15:24
Joined
Aug 4, 2016
Messages
57
I am looking for ways to open a form and filter for a specific PK number where the form to be opened is a subform of a main form with the subform "under" a tab strip control.

I want to Open the main and subform by clicking a textbox on a third form. The third form functions like a "Navigation" form.

Could a combination of DoCmd OpenForm methods accomplish this?

Thanks everyone
 
I would probably use the OpenArgs property, you can pass a string(s) to be used to perform any manner of operations in the OnLoad , Open etc events of the form being opened.
 
I put some time into making this work today. Here is what I have so far:

Private Sub Add_Comments_Click()
Dim EmployeeIDFilter As Integer

Me.txtEmployeeIDFilter.Value = EmployeeIDFilter
DoCmd.OpenForm "Client Main Form", acViewForm, , "ClientID = " & Me.txtClientIDFilter
DoCmd.Close acForm, "MenuItemEmployee"
DoCmd.GoToControl "Page17"
DoCmd.GoToControl "Client Employees"
DoCmd.FindRecord EmployeeIDFilter.Value

End Sub

[1] Does this look like I am on a path that will work?

[2] Why is EmployeeIDFilter on the last line an Invalid Qualifier?

[3] Can I modify the last line of code so that it will work?
 
[2] Why is EmployeeIDFilter on the last line an Invalid Qualifier?

EmployeeIDFilter is define as an integer which is a primitive and does need nor allow a qualifier. EmployeeIDFilter.Value would make sense to the compiler if EmployeeIDFilter were an control like a textbox.
 
Ok

I put a textbox on the "Client Employees" form and formatted it, and named it "txtEmployeeIDValue"

Then edited the code to read this way:

Private Sub Add_Comments_Click()
Dim EmployeeIDFilter As Long

Me.txtEmployeeIDFilter.Value = EmployeeIDFilter
DoCmd.OpenForm "Client Main Form", acViewForm, , "ClientID = " & Me.txtClientIDFilter
DoCmd.Close acForm, "MenuItemEmployee"
DoCmd.GoToControl "Page17"
DoCmd.GoToControl "Client Employees"
txtEmployeeIDValue.Value = EmployeeIDFilter
DoCmd.FindRecord txtEmployeeIDValue.Value

End Sub

the line:

txtEmployeeIDValue.Value = EmployeeIDFilter

is producing an "Object Required" error, and I cant figure out why.

Any guidance on this would be really appreciated.

Thanks
 
I got this to work with the following:

Private Sub Add_Comments_Click()
Dim EmployeeIDFilter As Integer

EmployeeIDFilter = Me.txtEmployeeIDFilter.Value
DoCmd.OpenForm "Client Main Form", acViewForm, , "ClientID = " & Me.txtClientIDFilter

Forms![Client Main Form]![Client Employee].Form!txtEmployeeIDValue.Value = EmployeeIDFilter
Forms![Client Main Form]![Client Employee].Form.Filter = "ClientEmployeeID=" & Forms![Client Main Form]![Client Employee].Form!txtEmployeeIDValue & ""

DoCmd.GoToControl "TabCtl15"
DoCmd.GoToControl "Page17"
DoCmd.GoToControl "Client Employee"

End Sub

One thing that is a little curious: sometimes txtEmployeeIDValue contains a number after running this code and sometimes it doesn't. Anyone have an idea why? Could this mean something is wrong?
 

Users who are viewing this thread

Back
Top Bottom