Open form carrying forward data

adams.bria

Registered User.
Local time
Today, 11:17
Joined
Apr 28, 2010
Messages
41
Here is what I would like to do. I have a "client center" where you bring up the demo data on a client. On frm_cli_center, I have buttons to open 4 different forms. When a button is clicked, I would like it to open the form, carrying forward the empl_id of the current record on the client center. If that empl_id already exists, I want it to open with the data that was already entered. Any help?
 
You can use the OpenArgs portion of the OpenForm command to pass information from the calling form, and then check that information in the On Load event of the form being called.
 
I am getting compile error, variable required, can't assign expression on the stremplid of If Len(strEmplID) > 0 Then.

here is what I am opening the form with
Code:
Private Sub Open_Client_Info_Click()
DoCmd.OpenForm "frm_client_info", acNormal, , , , acFormAdd, [Empl_ID]
End Sub

and here is the load code
Code:
Private Sub Form_Load()
Dim strEmplID() As String

strEmplID = Forms!frmclient_center.OpenArgs
If Len(strEmplID) > 0 Then
    DoCmd.GoToControl "empl_id"
    DoCmd.FindRecord strEmplID
  strOpenArgs = Split(Me.OpenArgs, ";")
End If
End Sub

Sorry this is my first time trying to do this, thanks.
 
Try;
Code:
Private Sub Open_Client_Info_Click()
DoCmd.OpenForm "frm_client_info", acNormal, , , , acFormAdd, Me.Empl_ID
End Sub
and
Code:
Private Sub Form_Load()
Dim strEmplID() As String

strEmplID = OpenArgs
If Len(strEmplID) > 0 Then
    DoCmd.GoToControl "empl_id"
    DoCmd.FindRecord strEmplID
  strOpenArgs = Split(Me.OpenArgs, ";") [COLOR="SeaGreen"]' I'm not sure what this line is doing ??[/COLOR]
End If
End Sub
 
Last edited:
My mistake, that line was from a previous experiment trying to get this to work.

I am still getting the compile error on strEmplid of "If Len(strEmplID) > 0 Then"


I've uploaded with appropriate forms/tables. Thanks
 

Attachments

Are you able to save that back to Access '03 as I don't currently have access to an '07 version.
 
Hopefully this works. Kept getting an error when I tried to convert using the access converter.

Pat, thanks for your help. That makes sense that you wouldn't want it to populate the FK before the user enters something. However, I am not really sure I understand what you are describing. Using the beforeinsert event you would create a command that populates the FK from the openargs data? So then you would also add a filter to the form open that would go to the open args empl if it exists? Is that correct?
 

Attachments

No seems to be corrupted. I should be able to look at the '07 version (it is '07 and not '10?) latter this arvo.
 
Ok, if you wouldn't mind helping, is this how it should be designed?

The data that needs to be filled out should be designed as a sub-form. The original form would be based on whatever table contains the original PK. Thus when the user clicks from the client_center, it would load with the Empl_ID on the master, as that is already entered. Then (using beforeinsert) when the user types into the form, it will pull Empl from the master, and populate into the sub_form table? Is that accurate?
 

Users who are viewing this thread

Back
Top Bottom