Using integers in variable names.

Discussion in 'Access Forms Coding' started by BrianDP, Jul 22, 2013.

  1. BrianDP

    BrianDP Guest

    Hello All- Seems like the Eval() function would help here somehow, but I can't seem to get it to work so I thought I'd explain it like this:

    I would like to take these statements, and instead of

    :
    : If (Nz(x0Receipt) > 0) And (Len(x0Callback) = 0) Then
    : MsgBox "Entry on Line 1 doesn't have an associated Receipt line."
    : End If
    :
    : If (Nz(x1Receipt) > 0) And (Len(x1Callback) = 0) Then
    : MsgBox "Entry on Line 2 doesn't have an associated Receipt line."
    : End If
    : .
    : .
    : .
    :
    : If (Nz(x9Receipt) > 0) And (Len(x9Callback) = 0) Then
    : MsgBox "Entry on Line 10 doesn't have an associated Receipt line."
    : End If
    :


    I would like something like:


    for ZZ = 0 to 9

    if (nz(xZZReceipt) > 0) and (Len(xZZCallback) = 0) then
    msgbox "The " & dhOrd(ZZ+1) & " Line doen't have an associated Receipt Line"
    end if

    next ZZ
     
    BrianDP, Jul 22, 2013
    #1
    1. Advertisements

  2. Are you simply repeating to allow more than one instance of something to be
    entered on that form in separate fields? If so, rethink your design, and
    consider using a "continuous forms view" form displaying multiple records.

    If not, (that is, if there is some compelling reason to re-implement
    displaying of multiple records on one form then look at using the type of
    reference to an object in a collection where you specifiy the name in text
    form, but instead of the literal name surrounded by quotes, refer to a
    variable containing the control name, and recalculate the variable
    containing the control name, using the index value of the loop, on each
    pass.

    --
    Larry Linson
    Microsoft Office Access MVP
    Co-Author, Microsoft Access Small Business Solutions, Wiley 2010

    "BrianDP" <> wrote in message
    news:...
    > Hello All- Seems like the Eval() function would help here somehow, but I
    > can't seem to get it to work so I thought I'd explain it like this:
    >
    > I would like to take these statements, and instead of
    >
    > :
    > : If (Nz(x0Receipt) > 0) And (Len(x0Callback) = 0) Then
    > : MsgBox "Entry on Line 1 doesn't have an associated Receipt line."
    > : End If
    > :
    > : If (Nz(x1Receipt) > 0) And (Len(x1Callback) = 0) Then
    > : MsgBox "Entry on Line 2 doesn't have an associated Receipt line."
    > : End If
    > : .
    > : .
    > : .
    > :
    > : If (Nz(x9Receipt) > 0) And (Len(x9Callback) = 0) Then
    > : MsgBox "Entry on Line 10 doesn't have an associated Receipt line."
    > : End If
    > :
    >
    >
    > I would like something like:
    >
    >
    > for ZZ = 0 to 9
    >
    > if (nz(xZZReceipt) > 0) and (Len(xZZCallback) = 0) then
    > msgbox "The " & dhOrd(ZZ+1) & " Line doen't have an associated Receipt
    > Line"
    > end if
    >
    > next ZZ
     
    Access Developer, Jul 23, 2013
    #2
    1. Advertisements

  3. BrianDP

    BrianDP Guest

    Larry,

    Thanks for your reply. I've seen the stuff You've been posting for years and I've always found it to be top notch.

    Well, the reason I'm repeating, and have this odd representation of data infields on a form to match whats going on in the subform, is in response toa request from the client. I thought it could have been done better by just having them enter the data into the subform, but they wanted it done this way, where the line items are displayed on the subform, and then the userwould key into fields out to the right, lined up next to the fields on thesubform. What a pain in the rump I'll tell you to keep that all synched up. Well, now that I have it working, what a kludge to get that to work, I'd like to tidy it up a bit, and one way I could see to do that would be to eliminate that large stanza in my code where I repeat that line over and over again with incrementing integers, with a for next loop, or a do while orsomething and reuse the code.

    I gather from your response, and from my past experience, that this is NOT possible.

    Since the code is already written, I'll just leave it. It's just a real problem though whenever I make a change to the workings of this thing as I morph it along, I have to apply any change 10 times!

    Thanks Larry.

    -Brian




    On Tuesday, July 23, 2013 12:15:12 AM UTC-4, Access Developer wrote:
    > Are you simply repeating to allow more than one instance of something to be
    >
    > entered on that form in separate fields? If so, rethink your design, and
    >
    > consider using a "continuous forms view" form displaying multiple records..
    >
    >
    >
    > If not, (that is, if there is some compelling reason to re-implement
    >
    > displaying of multiple records on one form then look at using the type of
    >
    > reference to an object in a collection where you specifiy the name in text
    >
    > form, but instead of the literal name surrounded by quotes, refer to a
    >
    > variable containing the control name, and recalculate the variable
    >
    > containing the control name, using the index value of the loop, on each
    >
    > pass.
    >
    >
    >
    > --
    >
    > Larry Linson
    >
    > Microsoft Office Access MVP
    >
    > Co-Author, Microsoft Access Small Business Solutions, Wiley 2010
    >
    >
    > > Hello All- Seems like the Eval() function would help here somehow, butI

    >
    > > can't seem to get it to work so I thought I'd explain it like this:

    >
    > >

    >
    > > I would like to take these statements, and instead of

    >
    > >

    >
    > > :

    >
    > > : If (Nz(x0Receipt) > 0) And (Len(x0Callback) = 0) Then

    >
    > > : MsgBox "Entry on Line 1 doesn't have an associated Receipt line."

    >
    > > : End If

    >
    > > :

    >
    > > : If (Nz(x1Receipt) > 0) And (Len(x1Callback) = 0) Then

    >
    > > : MsgBox "Entry on Line 2 doesn't have an associated Receipt line."

    >
    > > : End If

    >
    > > : .

    >
    > > : .

    >
    > > : .

    >
    > > :

    >
    > > : If (Nz(x9Receipt) > 0) And (Len(x9Callback) = 0) Then

    >
    > > : MsgBox "Entry on Line 10 doesn't have an associated Receipt line.."

    >
    > > : End If

    >
    > > :

    >
    > >

    >
    > >

    >
    > > I would like something like:

    >
    > >

    >
    > >

    >
    > > for ZZ = 0 to 9

    >
    > >

    >
    > > if (nz(xZZReceipt) > 0) and (Len(xZZCallback) = 0) then

    >
    > > msgbox "The " & dhOrd(ZZ+1) & " Line doen't have an associated Receipt

    >
    > > Line"

    >
    > > end if

    >
    > >

    >
    > > next ZZ
     
    BrianDP, Jul 25, 2013
    #3
  4. Did you look at whether my second suggestion might work for you? Referring
    to Controls is, in fact, referring to the Controls in the Form's collection
    of controls and one approach to referring to objects in a collection is to
    use the name in text form.

    Yep, I can hark back to a few times when the client was adamant about some
    not-very-good idea and I had to remind myself that "the customer isn't
    always right, but they are the one who's paying the bill". And, sometimes it
    led to an interesting development experience.

    --
    Larry Linson
    Microsoft Office Access MVP
    Co-Author, Microsoft Access Small Business Solutions, Wiley 2010

    "BrianDP" <> wrote in message
    news:...
    Larry,

    Thanks for your reply. I've seen the stuff You've been posting for years
    and I've always found it to be top notch.

    Well, the reason I'm repeating, and have this odd representation of data in
    fields on a form to match whats going on in the subform, is in response to a
    request from the client. I thought it could have been done better by just
    having them enter the data into the subform, but they wanted it done this
    way, where the line items are displayed on the subform, and then the user
    would key into fields out to the right, lined up next to the fields on the
    subform. What a pain in the rump I'll tell you to keep that all synched up.
    Well, now that I have it working, what a kludge to get that to work, I'd
    like to tidy it up a bit, and one way I could see to do that would be to
    eliminate that large stanza in my code where I repeat that line over and
    over again with incrementing integers, with a for next loop, or a do while
    or something and reuse the code.

    I gather from your response, and from my past experience, that this is NOT
    possible.

    Since the code is already written, I'll just leave it. It's just a real
    problem though whenever I make a change to the workings of this thing as I
    morph it along, I have to apply any change 10 times!

    Thanks Larry.

    -Brian




    On Tuesday, July 23, 2013 12:15:12 AM UTC-4, Access Developer wrote:
    > Are you simply repeating to allow more than one instance of something to
    > be
    >
    > entered on that form in separate fields? If so, rethink your design, and
    >
    > consider using a "continuous forms view" form displaying multiple records.
    >
    >
    >
    > If not, (that is, if there is some compelling reason to re-implement
    >
    > displaying of multiple records on one form then look at using the type of
    >
    > reference to an object in a collection where you specifiy the name in text
    >
    > form, but instead of the literal name surrounded by quotes, refer to a
    >
    > variable containing the control name, and recalculate the variable
    >
    > containing the control name, using the index value of the loop, on each
    >
    > pass.
    >
    >
    >
    > --
    >
    > Larry Linson
    >
    > Microsoft Office Access MVP
    >
    > Co-Author, Microsoft Access Small Business Solutions, Wiley 2010
    >
    >
    > > Hello All- Seems like the Eval() function would help here somehow, but
    > > I

    >
    > > can't seem to get it to work so I thought I'd explain it like this:

    >
    > >

    >
    > > I would like to take these statements, and instead of

    >
    > >

    >
    > > :

    >
    > > : If (Nz(x0Receipt) > 0) And (Len(x0Callback) = 0) Then

    >
    > > : MsgBox "Entry on Line 1 doesn't have an associated Receipt line."

    >
    > > : End If

    >
    > > :

    >
    > > : If (Nz(x1Receipt) > 0) And (Len(x1Callback) = 0) Then

    >
    > > : MsgBox "Entry on Line 2 doesn't have an associated Receipt line."

    >
    > > : End If

    >
    > > : .

    >
    > > : .

    >
    > > : .

    >
    > > :

    >
    > > : If (Nz(x9Receipt) > 0) And (Len(x9Callback) = 0) Then

    >
    > > : MsgBox "Entry on Line 10 doesn't have an associated Receipt
    > > line."

    >
    > > : End If

    >
    > > :

    >
    > >

    >
    > >

    >
    > > I would like something like:

    >
    > >

    >
    > >

    >
    > > for ZZ = 0 to 9

    >
    > >

    >
    > > if (nz(xZZReceipt) > 0) and (Len(xZZCallback) = 0) then

    >
    > > msgbox "The " & dhOrd(ZZ+1) & " Line doen't have an associated Receipt

    >
    > > Line"

    >
    > > end if

    >
    > >

    >
    > > next ZZ
     
    Access Developer, Jul 25, 2013
    #4
  5. Just in case Larry's being too cryptic for you,

    For ZZ = 0 To 9

    If (Nz(Me.Controls("x" & ZZ & "Receipt") > 0) and (Len(Me.Controls("x" &
    ZZ " & "Callback") = 0) Then
    MsgBox "The " & dhOrd(ZZ+1) & " Line doesn't have an associated Receipt
    Line"
    End If

    Next ZZ

    "Access Developer" wrote in message
    news:...

    Did you look at whether my second suggestion might work for you? Referring
    to Controls is, in fact, referring to the Controls in the Form's collection
    of controls and one approach to referring to objects in a collection is to
    use the name in text form.

    Yep, I can hark back to a few times when the client was adamant about some
    not-very-good idea and I had to remind myself that "the customer isn't
    always right, but they are the one who's paying the bill". And, sometimes it
    led to an interesting development experience.

    --
    Larry Linson
    Microsoft Office Access MVP
    Co-Author, Microsoft Access Small Business Solutions, Wiley 2010

    "BrianDP" <> wrote in message
    news:...
    Larry,

    Thanks for your reply. I've seen the stuff You've been posting for years
    and I've always found it to be top notch.

    Well, the reason I'm repeating, and have this odd representation of data in
    fields on a form to match whats going on in the subform, is in response to a
    request from the client. I thought it could have been done better by just
    having them enter the data into the subform, but they wanted it done this
    way, where the line items are displayed on the subform, and then the user
    would key into fields out to the right, lined up next to the fields on the
    subform. What a pain in the rump I'll tell you to keep that all synched up.
    Well, now that I have it working, what a kludge to get that to work, I'd
    like to tidy it up a bit, and one way I could see to do that would be to
    eliminate that large stanza in my code where I repeat that line over and
    over again with incrementing integers, with a for next loop, or a do while
    or something and reuse the code.

    I gather from your response, and from my past experience, that this is NOT
    possible.

    Since the code is already written, I'll just leave it. It's just a real
    problem though whenever I make a change to the workings of this thing as I
    morph it along, I have to apply any change 10 times!

    Thanks Larry.

    -Brian




    On Tuesday, July 23, 2013 12:15:12 AM UTC-4, Access Developer wrote:
    > Are you simply repeating to allow more than one instance of something to
    > be
    >
    > entered on that form in separate fields? If so, rethink your design, and
    >
    > consider using a "continuous forms view" form displaying multiple records.
    >
    >
    >
    > If not, (that is, if there is some compelling reason to re-implement
    >
    > displaying of multiple records on one form then look at using the type of
    >
    > reference to an object in a collection where you specifiy the name in text
    >
    > form, but instead of the literal name surrounded by quotes, refer to a
    >
    > variable containing the control name, and recalculate the variable
    >
    > containing the control name, using the index value of the loop, on each
    >
    > pass.
    >
    >
    >
    > --
    >
    > Larry Linson
    >
    > Microsoft Office Access MVP
    >
    > Co-Author, Microsoft Access Small Business Solutions, Wiley 2010
    >
    >
    > > Hello All- Seems like the Eval() function would help here somehow, but
    > > I

    >
    > > can't seem to get it to work so I thought I'd explain it like this:

    >
    > >

    >
    > > I would like to take these statements, and instead of

    >
    > >

    >
    > > :

    >
    > > : If (Nz(x0Receipt) > 0) And (Len(x0Callback) = 0) Then

    >
    > > : MsgBox "Entry on Line 1 doesn't have an associated Receipt line."

    >
    > > : End If

    >
    > > :

    >
    > > : If (Nz(x1Receipt) > 0) And (Len(x1Callback) = 0) Then

    >
    > > : MsgBox "Entry on Line 2 doesn't have an associated Receipt line."

    >
    > > : End If

    >
    > > : .

    >
    > > : .

    >
    > > : .

    >
    > > :

    >
    > > : If (Nz(x9Receipt) > 0) And (Len(x9Callback) = 0) Then

    >
    > > : MsgBox "Entry on Line 10 doesn't have an associated Receipt
    > > line."

    >
    > > : End If

    >
    > > :

    >
    > >

    >
    > >

    >
    > > I would like something like:

    >
    > >

    >
    > >

    >
    > > for ZZ = 0 to 9

    >
    > >

    >
    > > if (nz(xZZReceipt) > 0) and (Len(xZZCallback) = 0) then

    >
    > > msgbox "The " & dhOrd(ZZ+1) & " Line doen't have an associated Receipt

    >
    > > Line"

    >
    > > end if

    >
    > >

    >
    > > next ZZ
     
    Douglas J Steele, Jul 26, 2013
    #5
  6. "Douglas J Steele" <NOSPAM_djsteele@NOSPAM_gmail.com> wrote

    > Just in case Larry's being too cryptic for you,


    Hmm. You mean not everyone is fluent in Cryptic? <GRIN>

    I'm sorry I was obtuse and thanks, Doug, for picking up the thread.

    Larry
     
    Access Developer, Jul 27, 2013
    #6
  7. BrianDP

    BrianDP Guest

    Doug,

    Hey! That might be what I'm looking for! Sorry Larry for not beign able to decipher what you meant. Yes. I'll try writing it like that. I think it might work!

    -B


    On Monday, July 22, 2013 4:30:18 PM UTC-4, BrianDP wrote:
    > Hello All- Seems like the Eval() function would help here somehow, but I can't seem to get it to work so I thought I'd explain it like this:
    >
    >
    >
    > I would like to take these statements, and instead of
    >
    >
    >
    > :
    >
    > : If (Nz(x0Receipt) > 0) And (Len(x0Callback) = 0) Then
    >
    > : MsgBox "Entry on Line 1 doesn't have an associated Receipt line."
    >
    > : End If
    >
    > :
    >
    > : If (Nz(x1Receipt) > 0) And (Len(x1Callback) = 0) Then
    >
    > : MsgBox "Entry on Line 2 doesn't have an associated Receipt line."
    >
    > : End If
    >
    > : .
    >
    > : .
    >
    > : .
    >
    > :
    >
    > : If (Nz(x9Receipt) > 0) And (Len(x9Callback) = 0) Then
    >
    > : MsgBox "Entry on Line 10 doesn't have an associated Receipt line."
    >
    > : End If
    >
    > :
    >
    >
    >
    >
    >
    > I would like something like:
    >
    >
    >
    >
    >
    > for ZZ = 0 to 9
    >
    >
    >
    > if (nz(xZZReceipt) > 0) and (Len(xZZCallback) = 0) then
    >
    > msgbox "The " & dhOrd(ZZ+1) & " Line doen't have an associated Receipt Line"
    >
    > end if
    >
    >
    >
    > next ZZ
     
    BrianDP, Jul 31, 2013
    #7
  8. I'll have to try to be less cryptic.

    --
    Larry Linson
    Microsoft Office Access MVP
    Co-Author, Microsoft Access Small Business Solutions, Wiley 2010
     
    Access Developer, Aug 2, 2013
    #8
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.
Similar Threads
  1. Jim Jones

    " object variable or with block variable not set "

    Jim Jones, Sep 11, 2003, in forum: Access Forms Coding
    Replies:
    0
    Views:
    148
    Jim Jones
    Sep 11, 2003
  2. Michael Banks

    Error of Object Variable or With block variable not set

    Michael Banks, Oct 3, 2003, in forum: Access Forms Coding
    Replies:
    3
    Views:
    112
    Michael Banks
    Oct 3, 2003
  3. Rhonda Fischer

    => CboValue saved to variable & variable in Email subject line

    Rhonda Fischer, Mar 3, 2004, in forum: Access Forms Coding
    Replies:
    1
    Views:
    150
    Jonathan Parminter
    Mar 5, 2004
  4. ********
    Replies:
    2
    Views:
    138
    Jonathan Parminter
    Nov 8, 2004
  5. siddahuja

    Using variable names for controls

    siddahuja, Jan 6, 2005, in forum: Access Forms Coding
    Replies:
    2
    Views:
    103
    Marshall Barton
    Jan 6, 2005
  6. Jon A
    Replies:
    2
    Views:
    191
    Jon A
    Feb 26, 2005
  7. n1mbus

    Filtering a form by integers

    n1mbus, Nov 30, 2005, in forum: Access Forms Coding
    Replies:
    4
    Views:
    75
    Michael Miller
    Jan 4, 2006
  8. adrian
    Replies:
    1
    Views:
    79
    Douglas J. Steele
    Oct 13, 2006
Loading...