Results 1 to 6 of 6
  1. #1
    Join Date
    Feb 2010
    Posts
    11

    Unanswered: Printing A Record that has an Input Mask in the Primary Key Field

    I have figured out how to print a record to a report in access...

    Here is the code I'm using:

    Private Sub PrintWO_Click()
    On Error GoTo Err_PrintWO_Click

    Dim stDocName As String
    Dim strWhere As String

    stDocName = "2010 Service W/O Printing In Form"
    strWhere = "[Work Order Number] = """ & Me![Work Order Number] & """ "
    DoCmd.OpenReport stDocName, acViewPreview, , strWhere

    Exit_PrintWO_Click:
    Exit Sub

    Err_PrintWO_Click:
    MsgBox Err.Description
    Resume Exit_PrintWO_Click

    End Sub


    Ok...So here's my problem The [Work Order Number] field referenced here has an input mask of "10-"00000 and creates the auto numbers in sequence. When I use to print them, I would ask for the W/O # in the query as the criteria, and I would only be able to enter the last 5 digits without the "10-" which was the first part of the input mask. However, I figured if I was able to print a Customer information report (using the same code, but the [Customer Name] was the primary key), then I should be able to do it with the W/O's. However, I keep getting this message stating "Data Type Mismatch in Criteria Expression". Any ideas on how I can fix this so that I can print the record I'm looking at in the Service W/O form?

  2. #2
    Join Date
    Mar 2007
    Posts
    277
    This link has examples of using either a String value or a Numerical value and the difference. BTW, using an AutoNumber for an unbroken sequence of numbers is a bad idea.
    RuralGuy (RG for short) aka Allan Bunch MS Access MVP - acXP, ac07, ac10 - WinXP Pro, Win7 Pro
    Please reply to this forum so all may learn.

  3. #3
    Join Date
    Feb 2010
    Posts
    11
    Quote Originally Posted by RuralGuy View Post
    This link has examples of using either a String value or a Numerical value and the difference. BTW, using an AutoNumber for an unbroken sequence of numbers is a bad idea.
    Why is it a bad idea? It's the best way to have a numerical Work Order numbering system. I've got several people accessing this database and entering information. There's no way we can all keep up with the next number in line if it's not automatically generated.

  4. #4
    Join Date
    Mar 2007
    Posts
    277
    You may find this link of interest.
    RuralGuy (RG for short) aka Allan Bunch MS Access MVP - acXP, ac07, ac10 - WinXP Pro, Win7 Pro
    Please reply to this forum so all may learn.

  5. #5
    Join Date
    Feb 2010
    Posts
    11
    Thanks for the information. But for what we're using it for...it's the best way to manage our Work Order numbers. If we have a missing number then so be it. It's not the end of the world. I just need to figure out how to print the record that I'm looking at in the form, so all my people need to do is click a button to print the work order without having to enter the w/o number every time.

  6. #6
    Join Date
    Mar 2007
    Posts
    277
    OK, fair enough. Did the first link resolve this issue for you?
    RuralGuy (RG for short) aka Allan Bunch MS Access MVP - acXP, ac07, ac10 - WinXP Pro, Win7 Pro
    Please reply to this forum so all may learn.

Posting Permissions

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