OpenArgs not working

access7

Registered User.
Local time
Today, 07:58
Joined
Mar 15, 2011
Messages
172
Hello

Hoping someone may have time to look at the following...

I have a subform (SubFrm_Warnings) which I need to appear according to which company record is open on the form...

I have used OpenArgs on the DoCmd.OpenForm to set the companyref / ID number - this is working OK. I have now realised that although the correct company ID is now being set, the actually text box which contains any warnings is not linking to that company ID?

I know I must have to link this somehow... please could someone give me a clue as to which is the best approach...

The forms involved are Frm_Search (where the DoCmd.OpenForm is); Frm_Company (which is the main form which includes all the company info) and SubFrm_Warnings (which is to appear on open of the Company form should there be any warnings for that particular company.

I have attached the database and posted the relevant code below...

This code is on Frm_Search

Sub OpenCompanyForm()
'open the form
DoCmd.OpenForm "Frm_Company"
'run the Public GoToContact method, passing in the ContactRef selected in the list
Forms("Frm_Company").GoToContact Me.ListCompany

Dim stDocName As String
Dim intArgs
Dim stLinkCriteria As String

intArgs = Forms!Frm_Company.txtCompanyID
stDocName = "SubFrm_Warnings"

If Not IsNull(intArgs) Then
DoCmd.OpenForm stDocName, , , stLinkCriteria, , , intArgs
End If
'and close the search form
DoCmd.Close acForm, Me.Name
End Sub


This code is on SubFrm_Warnings

Private Sub Form_Load()

Me.txtCompanyRef = Me.OpenArgs

End Sub
 

Attachments

Thanks to anyone who took the time to view this post. I have now fixed the problem. I have changed the text box on the sub form to an unbound field and then used the same OpenArgs as I already had but rather than trying to get the company ref and then link via that I am now simply checking the text in the txtWarnings field on the company record that is open and then populating the unbound text box with that value.
PBaldy - I thank you for your reply, and the link, it could be useful for future things so thank you for that.
 

Users who are viewing this thread

Back
Top Bottom