Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2003
    Location
    Canberra, ACT Australia
    Posts
    53

    Unanswered: using a select statement in VB to compare the value with a user input

    Hi guys
    I have a form whereby the user has to input a value, with which I aim to compare the value with that held in a table field. I appear to be having trouble with syntax and placicing the table value in a form field. I want to do this after the 'update' in the user input field.

    I have triedin afterupdate - event procedure)
    1.
    dim usename as string

    select [tablename].[fieldname] from [tablename] where [tablename].[fieldname] = [forms]![formname].fieldcontent

    2.
    dim usename as string
    set usename = select [tablename].[fieldname] from [tablename] where [tablename].[fieldname] = [forms]![formname].fieldcontent

    3.
    The above with various combinations of brackets and parentheses.

    I am then going to use the result returned in a case statement in order to underttake further branching.

    Any help would be appreciated.

  2. #2
    Join Date
    Aug 2003
    Location
    Argentina
    Posts
    465

    Re: using a select statement in VB to compare the value with a user input

    Originally posted by rodmead
    Hi guys
    I have a form whereby the user has to input a value, with which I aim to compare the value with that held in a table field. I appear to be having trouble with syntax and placicing the table value in a form field. I want to do this after the 'update' in the user input field.

    I have triedin afterupdate - event procedure)
    1.
    dim usename as string

    select [tablename].[fieldname] from [tablename] where [tablename].[fieldname] = [forms]![formname].fieldcontent

    2.
    dim usename as string
    set usename = select [tablename].[fieldname] from [tablename] where [tablename].[fieldname] = [forms]![formname].fieldcontent

    3.
    The above with various combinations of brackets and parentheses.

    I am then going to use the result returned in a case statement in order to underttake further branching.

    Any help would be appreciated.
    For do that use the Dlookup function and in the beforeUpdate event, something like this:
    Dim varX As Variant
    varX = DLookup("[NombreCompañía]", "CompañíasEnvíos", "[IdCompañíaEnvíos] = " _
    & Forms!CompañíasEnvíos!IdCompañíaEnvíos)
    Me!usename = varX
    Saludos
    Norberto

  3. #3
    Join Date
    Oct 2003
    Location
    Roanoke, Va
    Posts
    445

    Smile Re: using a select statement in VB to compare the value with a user input

    Originally posted by Norberto
    For do that use the Dlookup function and in the beforeUpdate event, something like this:
    Dim varX As Variant
    varX = DLookup("[NombreCompañía]", "CompañíasEnvíos", "[IdCompañíaEnvíos] = " _
    & Forms!CompañíasEnvíos!IdCompañíaEnvíos)
    Me!usename = varX
    That Spanish/English mix is wild. It's got to be interesting coding in two languages. I have trouble with one.

    Gregg

  4. #4
    Join Date
    Jul 2003
    Location
    Canberra, ACT Australia
    Posts
    53

    Talking Re: using a select statement in VB to compare the value with a user input

    Originally posted by Norberto
    For do that use the Dlookup function and in the beforeUpdate event, something like this:
    Dim varX As Variant
    varX = DLookup("[NombreCompañía]", "CompañíasEnvíos", "[IdCompañíaEnvíos] = " _
    & Forms!CompañíasEnvíos!IdCompañíaEnvíos)
    Me!usename = varX
    many thanks.

    I used your advice successfully. I guess I was in a zone of using SQL statements and neglected to look at other options.

    once again, many thanks.


    Cheers

Posting Permissions

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