Simple Variable Question

jnfr

New member
Local time
Today, 08:06
Joined
Apr 11, 2008
Messages
6
I have a bunch of fields with different names, same format as txtMat# where # starts from 1 and onwards (txtMat1, txtMat2,...)

I want to write a code that's something like

If Not IsNull (txtMat#)

where the # can be controlled by a variable which increments by 1 in a do-while loop.

How can I do that?

If my # variable is called fieldNum, how can I essentially have something like

If Not IsNull (txtMat + fieldNum) where the entire entity of the bracket refers to the actual field with the name "txtMat + fieldNum"?

Thanks!
 
Use this:

Code:
If Not IsNull (Me.Controls("txtMat" & fieldNum))
 
Is there a certain way to refer to subforms in the IsNull function?

I'm trying to do something like this:

If Not IsNull(Me.Controls("Forms!frmSupplyChain!frmSCProduction.Form!txtMat" & fieldNum)) Then

where frmSupplyChain is my main, frmSCProduction is my subform

Thanks!
 
Code:
If Not IsNull(Me.Controls("YourSubformContainerControlNameHere").Form.Controls("Forms!frmSupplyChain!frmSCProduction.Form!txtMat" & fieldNum)) Then

Where YourSubformContainerControlNameHere is the name of the subform control that houses the subform on the main form (not necessarily the name of the subform, unless they are the same).
 

Users who are viewing this thread

Back
Top Bottom