Autofill fields in form based on another form

stevekos07

Registered User.
Local time
Today, 08:20
Joined
Jul 26, 2015
Messages
174
Hello. I have a form frmBaseCallSheets which displays client information in a continuous form. I would like to open another form frmEmergencyActivation from a command button, which will open this second form and select the ClientID from a combobox in frmEmergencyActivation based on the ClientID of the frmBaseCallSheets form. Other fields in frmEmergencyActivation autofill based on this selection now, but this would speed up the process.

Any assistance with the macro/code necessary to do this would be appreciated.
 
you can do it in frmEmergencyActivation Open event to change the form's recordset based on frmBaseCallSheet's ClienID field:

Private Sub Form_Open(Cancel As Integer)
Me.RecordSource = "Select * From yourSourceTable Where ClientID = " & Forms!frmBaseCallSheet!ClientID
End Sub
 
Thanks arnelgp. That kind of works, I get some fields filling ok, but others display an #Name? error.

This is the code I put in the On Load event:

Private Sub Form_Load()
Me.RecordSource = "Select ClientID From cboClientID.column(0) Where ClientID = " & Forms!frmBaseCallSheet!ClientID
End Sub

but got an error.

I have the following code to fill the related fields once the combobox is populated:

Private Sub cboClientID_AfterUpdate()
Me.txtMavisID.Value = Me.cboClientID.Column(1)
Me.txtFirstName.Value = Me.cboClientID.Column(2)
Me.txtLastName.Value = Me.cboClientID.Column(3)
Me.txBase.Value = Me.cboClientID.Column(4)
End Sub

To correctly select the ClientID from the combobox how should the code be written?
 
if you have a textbox for clientid (if you dont want to show it you can set its visible property to false):

Me.txtClientID = Me.cboClientID.Column(0)
 

Users who are viewing this thread

Back
Top Bottom