Carrying field values forward to the next record?

raward1941uk

Registered User.
Local time
Today, 14:14
Joined
Jan 21, 2008
Messages
14
I have created a series of 3 forms for entering order details. the first form records the customer reference, order no. and date. The second form contains details of the order eg., qty, description, and price. The third form contains details of the subcontracters and services they supply, including manufacturing costs. There may be 3 or 4 different suppliers doing various jobs to fulfill an order and therefore each supplier record for an order, must have the same order reference. How do I carry it forward from one record to the next. I am sure the solution is very simple but as the saying goes, "I can't see the wood for the trees."

raward1941uk
 
If you're saying you want to enter two or more successive records with the same order reference number, simply use the AfterUpdate event of the order reference number textbox to assign the current value to the its Default Value. The syntax varies depending on the datatype, so here's the code text and numeric and (for future reference) date as well:

For Text fields

Code:
Private Sub YourTextControlName_AfterUpdate()
If Not IsNull(Me.YourTextControlName.Value) Then
  YourTextControlName.DefaultValue = """" & Me.YourTextControlName.Value & """"
End If
End Sub
For Numeric fields

Code:
Private Sub YourNumericControlName_AfterUpdate()
If Not IsNull(Me.YourNumericControlName.Value) Then
  YourNumericControlName.DefaultValue = Me.YourNumericControlName.Value
End If
End Sub
For Date fields

Code:
Private Sub YourDateControlName_AfterUpdate()
If Not IsNull(Me.YourDateControlName.Value) Then
  YourDateControlName.DefaultValue ="#" &  Me.YourDateControlName & "#"
End If
End Sub
 
Thank you: I said I couldn't see the wood for the trees.
raward1941uk
 
Hi,

if the 2nd & third forms also have data entered, then you could simply set the default value of field in form 2 to that of form 1 and then the same from form 3 to form 2 so in effect, form 2 field value is defaulted to that of form 1 and form 3 will be defaulted to form 2 for example:

=Forms![formName]![FieldName]

place that in the default value of the relevant areas in the forms. this, if you decide to cancel, no records are made whereas code might make the entry for you.

i have attached an example.

check out the default values on each form. the forms are opened based on order numbers but can be changed to anything else.

NS
 

Attachments

Nigel,

Thank you very much. I have tried it and it works beautifully; best of all, it's very simple.

Roger Ward
 

Users who are viewing this thread

Back
Top Bottom