Multiple Query text boxes on a single form - MS ACCESS 2003

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Josephbupe
    New Member
    • Jan 2008
    • 7

    #1

    Multiple Query text boxes on a single form - MS ACCESS 2003

    Please, i don't know about programming i want to learn. I am creating a motor vehicle database and i need three text boxes on a single form for carrying out queries. The text boxes are: (VIN) (Begin Date) (End Date), so the user can query either by VIN or by Begin Date End Date.

    How may i do this, or is there any code that can be customised to suite my need?

    I will appreciate your response.
  • sierra7
    Recognized Expert Contributor
    • Sep 2007
    • 446

    #2
    Joseph
    If you don't know about Access or programming then the best thing is to start by reading the Help within Access.

    You need to look-up topics on;-
    About Tables
    Create a Table
    About Forms
    Create Form
    About Filters
    Applying a Filter

    They will give you a good start on how and why to do things. The topics are better illustrated than an explanation that can be given here.

    If I have mis-understood your capabilities and you don't want your users to learn to Filter By Form to apply a filter, then you will need to create the three text boxes in the Header area of your form.

    You will need three public string variables, lets call then sVIN, sBegin, & sEnd

    in the After_Update event of txtVIN you need something like
    Code:
     If Me.txtVIN= "" Then 
    sVIN = "[VIN] <0"
    Else
    sVIN = "[VIN]= '" & Me.txtVIN & "'"
    EndIf
     
    DisplayData
    Have assumed VIN is alpha-numeric
    In the After_Update event of txtBeginDate you will need
    Code:
     If Me.txtBeginDate = "" Then 
    sBegin=""
    Else
    sBegin = " and [BeginDate] =#" & Me.txtBeginDate & "#"
    EndIf
     
    DisplayData
    You will need a similar statement in the After_Update event of txtEndDate and it is presument that the field nmes of your database are [VIN], [BeginDate] and [EndDate]
    You will need a module called DisplayData which will be like;=
    Code:
     Private Sub DisplayData() 
    Dim strCriteria as String
     
    strCriteria = sVin & sBegin & sEnd
    Me.Filter = strCriteria
    Me.Filter = On
     
    End Sub
    Let's know how you get on

    S7

    Comment

    Working...