Results 1 to 8 of 8
  1. #1
    Join Date
    Oct 2006
    Posts
    7

    Unanswered: Serious NooB Access question

    I am in the process of building an Access database to track desktops, laptops and such. I built a form to perform entries for new systems. I have a combobox that lists 4 static items: Center, Onsite, Virtual and Other. Is there a way to call a new form (or subform) upon selecting just Virtual? Nothing needs to occur upon selecting any of the other entries. Could I use an expression? or perhaps a macro? Any assistance would be greatly appreciated!

  2. #2
    Join Date
    Jul 2006
    Posts
    108
    yes you can, but i dont have a direct copy of access at hand, ill get back to you as soon as i get home.
    Oh and BTW there is no such thing as a noob question, only a question from a noobie.

  3. #3
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    I'd use VBA in the after update event of that combo. Code would be like:

    Code:
    If Me.ComboName = "Virtual" Then
      'your code to open other form here
    End If
    Paul

  4. #4
    Join Date
    Oct 2006
    Posts
    7

    Unhappy The NooB question cont...

    I think I am in way over my head with this project... LOL I attempted several variations of the sample code provided on the above post to no avail... It is quite obvious I need to stick to Networking!!

    The name of the combobox is: Location
    The name of the form is: Frm_VirtualUserEntryForm
    Actual Text from ComboBox Selection: Virtual User

    I seem to be missing the ME.?????? Am I to replace the ME with some other statement?

    If Me.ComboName = "Virtual" Then
    'your code to open other form here
    End If

    My Variations:

    Private Sub Location_AfterUpdate()
    If Me.Location = "Virtual User" Then
    DoCmd.OpenForm (Frm_VirtualUserEntryForm)
    End If
    End Sub

    Private Sub Location_AfterUpdate()
    If Location.ComboBox = "Virtual User" Then
    DoCmd.OpenForm (Frm_VirtualUserEntryForm)
    End If
    End Sub

    Private Sub Location_AfterUpdate()
    If ComboBox.Location = "Virtual User" Then
    DoCmd.OpenForm (Frm_VirtualUserEntryForm)
    End If
    End Sub

  5. #5
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Well you got the AfterUpdate event part right ... Since you've named the combobox in question ...

    If Location.Value="Virtual User" then
    Docmd.Openform ....
    Endif


    Some like to use Me.Location or Forms!MyFormNameHere!Location or some other variations ... It's all up to you on how you prefer to refence objects/controls on your form ...

    Also, the .Value method uses the BoundColumn to determine what is returned as the value ... you can display column(s) and return values from hidden ones ...
    Back to Access ... ADO is not the way to go for speed ...

  6. #6
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Your first one was right, but OpenForm takes a string, so try this:

    Code:
    Private Sub Location_AfterUpdate()
    If Me.Location = "Virtual User" Then
      DoCmd.OpenForm "Frm_VirtualUserEntryForm"
    End If
    End Sub
    Paul

  7. #7
    Join Date
    Jul 2006
    Posts
    108
    the "me." part its just a very simple way of saying
    "forms!Frm_VirtualUserEntryForm!location" it makes it alot easier as you can see

  8. #8
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Quote Originally Posted by jwalker343
    the "me." part its just a very simple way of saying
    "forms!Frm_VirtualUserEntryForm!location"
    To clarify, "Me" will refer to the object (form/report) that it appears in. In this case, "Frm_VirtualUserEntryForm" is the form to be opened, not the form containing the running code. Therefore, "Me" does not refer to that form here, it refers to the form that the Location combo is on.

    I suspect jwalker knows that but didn't realize there were 2 forms involved here.
    Paul

Posting Permissions

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