After Update Fill

S

ServiceEnvoy

I have a Customer Record Form called "FRM_FireytechCustomers"
I have a New Ticket Data Entry Form called "DataEntry-Fireytech"

I currently have the following code which is the onclick event of a
button called "FireytechTicket" which takes us to the Data Entry Form
and automatically carries the customer id number to the data entry
form. Here is the code for the button currently:

Private Sub FireytechTicket_Click()
On Error GoTo Err_FireytechTicket_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "DataEntry-Fireytech"
DoCmd.OpenForm stDocName, , , acFormAdd
Forms(stDocName)![CustomerID] = Me.[CustomerID]
Exit_FireytechTicket_Click:
Exit Sub

Err_FireytechTicket_Click:
MsgBox Err.Description
Resume Exit_FireytechTicket_Click
End Sub

I have an after update on the data entry form for the field customerid
so that when we enter the customer id it auto fills all the customer
data on the data entry form so it is displayed in our ticketing system
for quick visual reference without having to look up the customer id
number. Here is the code for the after update:

Private Sub CustomerID_AfterUpdate()
Me.CustomerID.Requery
Me.NameLast = Me.CustomerID.Column(1)
Me.NameFirst = Me.CustomerID.Column(2)
Me.CompanyName = Me.CustomerID.Column(3)
Me.PhoneWork = Me.CustomerID.Column(4)
Me.PhoneWorkExt = Me.CustomerID.Column(5)
Me.PhoneHome = Me.CustomerID.Column(6)
Me.PhoneMobile = Me.CustomerID.Column(7)
Me.Address = Me.CustomerID.Column(8)
Me.Address2 = Me.CustomerID.Column(9)
Me.AddressCity = Me.CustomerID.Column(10)
Me.AddressState = Me.CustomerID.Column(11)
Me.AddressZip = Me.CustomerID.Column(12)
Me.Email = Me.CustomerID.Column(13)
Me.PaymentTerms = Me.CustomerID.Column(14)
End Sub

I would like to have all of the after update data listed above
automatically entered when we click the fireytech tickets button. It
currently only brings the customer id with it to the new form but I
would like all of these other fields to carry to the new form to
eliminate one more data entry step/click. How would I do that?
 
K

Klatuu

The main problem is that a form control After Update event does not fire when
loaded programmatically. It only fires when a user types information into it
then move away from it.

Here is a better way to do it and will actually be faster to execute and
take less code.
Rather than unbound controls on DataEntry-Fireytech, put a subform control
on it. Use a subform with a query based on the customer table that includes
the fields you want to display. Now here is a modification to your openform
that will pass the customerId as an OpenArg

Private Sub FireytechTicket_Click()
On Error GoTo Err_FireytechTicket_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "DataEntry-Fireytech"
DoCmd.OpenForm stDocName, , , acFormAdd, , , Me.CustomerID
Exit_FireytechTicket_Click:
Exit Sub

Add
Then in the Load Event of DataEntry-Fireytech:

If Not IsNull(Me.OpenArgs) Then
Me.CustomerID = Me.OpenArgs
Me.CustomerSubform.Form.Requery
End If

This will cause the subform to show the customer record for the customerID
received from the other form.
--
Dave Hargis, Microsoft Access MVP


ServiceEnvoy said:
I have a Customer Record Form called "FRM_FireytechCustomers"
I have a New Ticket Data Entry Form called "DataEntry-Fireytech"

I currently have the following code which is the onclick event of a
button called "FireytechTicket" which takes us to the Data Entry Form
and automatically carries the customer id number to the data entry
form. Here is the code for the button currently:

Private Sub FireytechTicket_Click()
On Error GoTo Err_FireytechTicket_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "DataEntry-Fireytech"
DoCmd.OpenForm stDocName, , , acFormAdd
Forms(stDocName)![CustomerID] = Me.[CustomerID]
Exit_FireytechTicket_Click:
Exit Sub

Err_FireytechTicket_Click:
MsgBox Err.Description
Resume Exit_FireytechTicket_Click
End Sub

I have an after update on the data entry form for the field customerid
so that when we enter the customer id it auto fills all the customer
data on the data entry form so it is displayed in our ticketing system
for quick visual reference without having to look up the customer id
number. Here is the code for the after update:

Private Sub CustomerID_AfterUpdate()
Me.CustomerID.Requery
Me.NameLast = Me.CustomerID.Column(1)
Me.NameFirst = Me.CustomerID.Column(2)
Me.CompanyName = Me.CustomerID.Column(3)
Me.PhoneWork = Me.CustomerID.Column(4)
Me.PhoneWorkExt = Me.CustomerID.Column(5)
Me.PhoneHome = Me.CustomerID.Column(6)
Me.PhoneMobile = Me.CustomerID.Column(7)
Me.Address = Me.CustomerID.Column(8)
Me.Address2 = Me.CustomerID.Column(9)
Me.AddressCity = Me.CustomerID.Column(10)
Me.AddressState = Me.CustomerID.Column(11)
Me.AddressZip = Me.CustomerID.Column(12)
Me.Email = Me.CustomerID.Column(13)
Me.PaymentTerms = Me.CustomerID.Column(14)
End Sub

I would like to have all of the after update data listed above
automatically entered when we click the fireytech tickets button. It
currently only brings the customer id with it to the new form but I
would like all of these other fields to carry to the new form to
eliminate one more data entry step/click. How would I do that?
 
S

ServiceEnvoy

Ok, I think I understand and I've tried to incorporate the suggestions
from the last post. I have modified the code of the button
"FireytechTicket" located on the "FRM_FireytechCustomers" Form to the
following:

Private Sub FireytechTicket_Click()
On Error GoTo Err_FireytechTicket_Click


Dim stDocName As String
Dim stLinkCriteria As String


stDocName = "DataEntry-Fireytech"
DoCmd.OpenForm stDocName, , , acFormAdd, , , Me.CustomerID
Exit_FireytechTicket_Click:
Exit Sub

Err_FireytechTicket_Click:
MsgBox Err.Description
Resume Exit_FireytechTicket_Click
End Sub

It successfully takes me to the data entry form "DataEntry-Fireytech",
opens the form and puts the customerID from the FRM_FireytechCustomers
Form into the data entry form DataEntry-Fireytech.

I added the "on load" event procedure of the DataEntry-Fireytech form
as suggested above. Here is the code with corrections for the correct
form names:

Private Sub Form_Load()
If Not IsNull(Me.OpenArgs) Then
Me.CustomerID = Me.OpenArgs
Me.SUB_FireytechCustomerData.Form.Requery
End If
End Sub

I added a subform to the DataEntry-Fireytech form called
Sub_FireytechCustomerData and based the subform off of a query
containing the customer data that I would want to display in the
fields on the data entry form. When I hit the button, I am taken to
the correct form, the customerID from the FRM_FireytechCustomers Form
is brought to the customerID field in the DataEntry-Fireytech form and
I can see matching data in the subform but the related fields in the
data entry form are not populated.

Did I miss something?
 
K

Klatuu

Are you using the Link Master Field(s) and Link Child Field(s) in the subform
control to relate the customer record to the ticket record?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top