Generic code

DrAtsab

New member
Local time
Today, 10:31
Joined
Mar 26, 2008
Messages
8
I have a form in which I have a sub form containing multiple rows. All the rows contain the same text boxes and combo boxes – all named the same but with the row number on the end of the name:

txtFName1 txtSName1 txtAmt1 txtDiscount1 txtTotal1
txtFName2 txtSName2 txtAmt2 txtDiscount2 txtTotal2
txtFName3 txtSName3 txtAmt3 txtDiscount3 txtTotal3

After updating the discount in each row a routine runs that populates the total field with the difference between Amt & Discount – the data is then added to a table.

Is there a way of writing a generic block of code which I can pass a number to and run the block of code using that number as a variable and concatenate it to the end of the name of each txtbox to save writing out the code for each row?

Currently the code goes something like this:

Me.txtTotal1 = Me.txtAmt1 – txtDiscount1

Rs.AddNew
Rs(“FN”) = Me.txtFName1
Rs(“SN”) = Me.txtSName1
Rs(“Tot”) = Me.txtTotal1
Rs.Update
 
This help?

Me("txtFName" & Variable)
 
Thanks

Thanks for that - i thought it would be simple but just couldn't find the syntax anywhere:)
 

Users who are viewing this thread

Back
Top Bottom