Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2004
    Location
    Texas
    Posts
    37

    Unanswered: I want to use a variable to ...

    ' I would like to use the "line" variable for the rsttbl![field] argument ...
    ' I assume this is possible ... just don't know the syntax


    Dim Line As String
    Dim dbs As Database, rsttbl As Recordset

    Set dbs = CurrentDb
    Set rsttbl = dbs.OpenRecordset("table") 'fieldnames= rsttbl!W1 & rsttbl!W2

    Line = Me.Combo21 'combo21 = either "W1" or "W2"

    If Me.Combo21 = "W1" Then

    If rsttbl!W1 = [criteria] Then
    Else
    End If

    End If

    If Me.Combo21 = "W2" Then

    If rsttbl!W2 = [criteria] Then
    Else
    End If

    End If

    ' I actually have quite a few more fields so using a var would be great
    A2K - W2k
    Thanks & Regards
    Pete

  2. #2
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713

    Re: I want to use a variable to ...

    Originally posted by pltx2000
    ' I would like to use the "line" variable for the rsttbl![field] argument ...
    ' I assume this is possible ... just don't know the syntax


    Dim Line As String
    Dim dbs As Database, rsttbl As Recordset

    Set dbs = CurrentDb
    Set rsttbl = dbs.OpenRecordset("table") 'fieldnames= rsttbl!W1 & rsttbl!W2

    Line = Me.Combo21 'combo21 = either "W1" or "W2"

    If Me.Combo21 = "W1" Then

    If rsttbl!W1 = [criteria] Then
    Else
    End If

    End If

    If Me.Combo21 = "W2" Then

    If rsttbl!W2 = [criteria] Then
    Else
    End If

    End If

    ' I actually have quite a few more fields so using a var would be great
    What are you trying to do???? Your code fragment doesn't make any sense ...

  3. #3
    Join Date
    Jan 2004
    Location
    Texas
    Posts
    37
    I'll try again, here's a new example:

    Dim dbs As Database, tblSales As Recordset

    Set dbs = CurrentDb
    Set tblSales = dbs.OpenRecordset("sales")

    ' Sales table has 2 fields salesman1 & salesman2
    ' Sales table has 1 record and salesman1 & salesman2 is set to either True or False - It's a status holder

    ' In my form I have a combobox with the choice of either
    salesman1 or salesman2

    ' I want to be able to use the value from the combobox as the field pointer in the If statement but I can't seem to find the right syntax it either won't compile or I get error messages when process the form.

    tblSales.MoveFirst

    If tblSales!Me.Combobox = True Then
    Else
    End If
    A2K - W2k
    Thanks & Regards
    Pete

Posting Permissions

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