Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2011
    Posts
    2

    Unanswered: Access 2007 VBA If Statement

    Hi All

    I would really really appreciate some help on this:

    I have a form that has command buttons on, when clicking a button I update a table saying what queries have been run. What I now need to do is use the information in that table to Enable and Disable the button when opening the form.

    I basically want to say:

    if [mytable].[button] = 1 and [mytable].[yes/no] = yes then
    Me.Step_1.Enabled = False
    elseif [mytable].[button] = 1 and [mytable].[yes/no] = no then
    Me.Step_1.Enabled = True

    Many Thanks

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    VBA is not the same beastie as Visual Basic. its an almost incestuous product, but it is different.

    Primarily seen on Microsoft Office products (but it has also appeared in other vendors products)

    Ideally you should post your question in the relevant forum (or closest relative), rather than the VB forums

    however its should be something close to

    Code:
    if [mytable].[aColumn] = 1 and [mytable].[bColumn] = vbTrue then
      Me.Step_1.Enabled = False
    elseif [mytable].[button] = 1 and [mytable].[yes/no] = no then
      Me.Step_1.Enabled = True
    endif
    you can short circuit this to
    Code:
    Me.Step_1.Enabled =  not([mytable].[aColumn] = 1 and [mytable].[bColumn] = vbTrue)
    however its hard to say given that we don't know what environment you are using this code in
    we don't know whether mytable.whatever is a column in a table/recordset, a control on a from or report, a variable.....
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Nov 2011
    Posts
    2
    Ok thank you, I shall try this and if not then will move to a more suitiable forum. But thank you for your help.

Posting Permissions

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