Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2011
    Posts
    2

    Unanswered: DoCmd.OpenForm where part number is between X and Y

    I Want to open a from where it will only have access to records that field PartNumber is between 112-0000-000 and 112-9999-999. Not sure of the proper format of the where statement i.e. " ' & ect.


    Private Sub GpFm1_AfterUpdate()
    Select Case GpFrm1
    Case 1
    DoCmd.OpenForm "FrmPartsUpdate", acNormal, , PartNumber Between ""112-0000-000"" And ""112-5999-999"", acEdit, acNormal

  2. #2
    Join Date
    Feb 2004
    Location
    Chicago, IL
    Posts
    1,312
    I would think this would work:

    DoCmd.OpenForm "FrmPartsUpdate", acNormal, , "PartNumber Between '112-0000-000' And '112-5999-999'", acEdit, acNormal

  3. #3
    Join Date
    Jan 2011
    Posts
    2

    The code didn't work or I have a typo

    The code didn't work or I have a typo. I have a form with 26 buttons in 2 groups of 13 called GpFrm1 and GpFrm2. I have this working with macros but some one once told me never use macros. What happens is when button pressed form doesn't come up at all. here is code for GpFm1.

    Private Sub GpFm1_AfterUpdate()
    Select Case GpFrm1
    Case 1
    DoCmd.OpenForm "FrmPartsUpdate", acNormal, , "PartNumber Between '112-0000-000'And '112-5999-999'", acEdit, acNormal
    ' Tags and Lables (Printed Outside)
    Case 2
    ' Printed Circuit Boards, Probe Cards, Flrx Circuits
    DoCmd.OpenForm "FrmPartsUpdate", acNormal, , "PartNumber Between '150-0000-000' And '150-9999-999' Or Between '250-0000-000' And '250-9999-999'", acEdit, acNormal
    Case 3
    ' Resistors
    DoCmd.OpenForm "FrmPartsUpdate", acNormal, , "PartNumber Between '151-0000-000' And '151-5999-999'", acEdit, acNormal
    Case 4
    ' Resistors Network
    DoCmd.OpenForm "FrmPartsUpdate", acNormal, , "PartNumber Between '151-6000-000' And '151-6999-999'", acEdit, acNormal
    Case 5
    ' Resistors Pots
    DoCmd.OpenForm "FrmPartsUpdate", acNormal, , "PartNumber Between '151-7000-000' And '151-7999-999'", acEdit, acNormal
    Case 6
    ' Capacitors Tantalum
    DoCmd.OpenForm "FrmPartsUpdate", acNormal, , "PartNumber Between '152-0000-000' And '152-9999-999'", acEdit, acNormal
    Case 7
    ' Capacitors Electrolytic
    DoCmd.OpenForm "FrmPartsUpdate", acNormal, , "PartNumber Between '153-0000-000' And '153-9999-999'", acEdit, acNormal
    Case 8
    ' Capacitors Bypass
    DoCmd.OpenForm "FrmPartsUpdate", acNormal, , "PartNumber Between '154-0000-000' And '154-9999-999'", acEdit, acNormal
    Case 9
    ' Diodes, Ic's, Leds, Transistors, Regulators Optocouplers
    DoCmd.OpenForm "FrmPartsUpdate", acNormal, , "PartNumber Between '155-0000-000' And '155-9999-999'", acEdit, acNormal
    Case 10
    ' Relay's
    DoCmd.OpenForm "FrmPartsUpdate", acNormal, , "PartNumber Between '156-0000-000' And '156-9999-999'", acEdit, acNormal
    Case 11
    ' Mis. Electrical Hardware
    DoCmd.OpenForm "FrmPartsUpdate", acNormal, , "PartNumber Between '158-0000-000' And '158-0999-999'", acEdit, acNormal
    Case 12
    ' Pogo Pins
    DoCmd.OpenForm "FrmPartsUpdate", acNormal, , "PartNumber Between '158-1000-000' And '158-1999-999'", acEdit, acNormal
    Case 13
    ' Pogo Pins Cables
    DoCmd.OpenForm "FrmPartsUpdate", acNormal, , "PartNumber Between '158-2000-000' And '158-2999-999'", acEdit, acNormal
    End Select

    GpFrm1 = Null

    End Sub

  4. #4
    Join Date
    Feb 2004
    Location
    Chicago, IL
    Posts
    1,312
    The Where condition is going to be the same as what you have in an SQL statement. I would suggest getting the syntax correct in a query first. Then copy and paste the WHERE condition. Use the Query designer to create the query then switch to SQL view and copy what comes after WHERE.

    After you copy, make sure your string has double quotes around it. If you want... paste the WHERE condition and someone can help with the syntax for the Where parameter.

Posting Permissions

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