Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2004

    Question Unanswered: VB Field Reference

    I have a form that has several field checkboxes and based on conditions user selects, it fills these field Yes/No boxes. The first instance is to select all boxes but limit to a certain number. I am having a hard time trying to take a string and to reference it to a field and making the field name change in the for next statement. Tried using "Fields" and "Value" but come up with problems. HELP. How to get "myval" to reference the field? See snip below:

    Private Sub packEvery_Click()
    Dim NumOfWpSQL As String
    Dim NumofWP As Integer
    Dim WPCount As Integer
    Dim wpnumb As Integer

    For x = 1 To NumofWP
    wpnumb = WPCount + 1
    WPfield = "[wp" & wpnumb & "]"
    WPCount = WPCount + 1
    Rem Forms![FRMWPSELECTION]![FRMWIPWP Subform].Form![wp8] = True
    myval = "Forms![FRMWPSELECTION]![FRMWIPWP Subform].Form!" & WPfield
    Next x
    End Sub

  2. #2
    Join Date
    Nov 2003
    Sussex, England

    Er ...

    I'm not sure what you're trying to do, but until you give NumofWP a value your loop is going from 1 to 0.

  3. #3
    Join Date
    Jun 2004
    Florida, US
    I believe you need to use Eval() function to do this. Also as Ryker said, you need to initialize NumofWP to make your loop work correctly.

  4. #4
    Join Date
    Nov 2003
    Use Me.Controls("blah, blah" & blah & "blah")

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts