Results 1 to 10 of 10
  1. #1
    5 Star Lounger bfxtrfcmgr's Avatar
    Join Date
    Aug 2002
    Location
    Fresno, California, USA
    Posts
    995
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Code help stLinkCriteria (2002 SP-2)

    I am getting the (attached) error in the following code. When I step through the procedure there is a Null value in txtRelease1No, but I can't seem to discover why that is. Little help?

    <pre>Private Sub cmdDeliveryConfirm_Click()
    On Error GoTo Err_cmdDeliveryConfirm_Click

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "rptDeliveryConfirm"
    stLinkCriteria = "[txtRelease1No]=" & Me![txtRelease1No]
    DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria

    Exit_cmdDeliveryConfirm_Click:
    Exit Sub

    Err_cmdDeliveryConfirm_Click:
    MsgBox Err.Description
    Resume Exit_cmdDeliveryConfirm_Click

    End Sub</pre>

    Attached Images Attached Images
    Bryan,
    Not the smartest critter on the glacier. . .
    . . .but I'm persistent (does that count?)

  2. #2
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Jerusalem, Israel
    Posts
    708
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Code help stLinkCriteria (2002 SP-2)

    Is Me![txtRelease1No] a bound control that was just filled in, and the record not yet saved.
    Try adding at the beginning of the code
    If Me.Dirty = True Then Me.Dirty = False

  3. #3
    5 Star Lounger bfxtrfcmgr's Avatar
    Join Date
    Aug 2002
    Location
    Fresno, California, USA
    Posts
    995
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Re: Code help stLinkCriteria (2002 SP-2)

    Zave:

    Thanks for the reply but, no, txtRelease1No is entered at the time the record is created; the data already exists on the form at the time the cmdbtn is clicked to invoke the code.
    Bryan,
    Not the smartest critter on the glacier. . .
    . . .but I'm persistent (does that count?)

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Code help stLinkCriteria (2002 SP-2)

    Are you sure that the txtRelease1No control is indeed the one you need? If you select the control named txtRelease1No on the form in design view, what is its Control Source property?

  5. #5
    2 Star Lounger
    Join Date
    Mar 2004
    Location
    Cincinnati, Ohio, USA
    Posts
    102
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Code help stLinkCriteria (2002 SP-2)

    This line looks suspect:

    stLinkCriteria = "[txtRelease1No]=" & Me![txtRelease1No]

    I would try

    stLinkCriteria = "[txtRelease1No]='" & Me![txtRelease1No] & "'"

    If I'm reffering to a string, I generally have a single apostrophe before and after the value.

    -Mike

  6. #6
    5 Star Lounger bfxtrfcmgr's Avatar
    Join Date
    Aug 2002
    Location
    Fresno, California, USA
    Posts
    995
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Re: Code help stLinkCriteria (2002 SP-2)

    Hans:

    Control Source = txtRelease1No
    Bryan,
    Not the smartest critter on the glacier. . .
    . . .but I'm persistent (does that count?)

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Code help stLinkCriteria (2002 SP-2)

    FlyerMike's suggestion was the first thing I thought of, so I would certainly check that if I were you. But your remark that txtRelease1No is Null while it shouldn't be makes me suspicious.

  8. #8
    5 Star Lounger bfxtrfcmgr's Avatar
    Join Date
    Aug 2002
    Location
    Fresno, California, USA
    Posts
    995
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Re: Code help stLinkCriteria (2002 SP-2)

    Hans:

    After playing with this every which way I could think of, I finally came up with...

    stLinkCriteria = "[txtRelease1No]=" & "'" & Me![txtRelease1No] & "'"

    . . .although I still don't get why the original doesn't work (it works elsewhere when opening a form)

    Thanks to all for your input!
    Bryan,
    Not the smartest critter on the glacier. . .
    . . .but I'm persistent (does that count?)

  9. #9
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Code help stLinkCriteria (2002 SP-2)

    That is FlyerMike's suggestion (with a minor change). It means that txtRelease1No, despite the name ending in No, is a text field - text values must always be surrounded in quotes - and that the mention of Null was a red herring.

    Your original code works for a number field, not for a text field.

  10. #10
    5 Star Lounger bfxtrfcmgr's Avatar
    Join Date
    Aug 2002
    Location
    Fresno, California, USA
    Posts
    995
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Re: Code help stLinkCriteria (2002 SP-2)

    Hans:

    . . .which would explain why it worked elsewhere (Long Integer). Fishing produced more than just "herring" <img src=/S/grin.gif border=0 alt=grin width=15 height=15>, thanks for the explanation!!
    Bryan,
    Not the smartest critter on the glacier. . .
    . . .but I'm persistent (does that count?)

Posting Permissions

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