Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2003
    Posts
    11

    Unanswered: open form to show specific record...

    I have been opening a form using a command button for ages now with no problem (I think I used the command button wizard to do it originally), but now it has stopped working.

    ==========================
    Private Sub BTN_VIEWQUOTE_Click()

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "FRM_QUOTES"
    stLinkCriteria = "[QUOTEID]=" & Me.QUOTEID
    DoCmd.OpenForm stDocName, , , stLinkCriteria
    End Sub
    ==========================

    The form opens, but it displays a new record, rather than the one specified by the link criteria.

    I have to hit 'Apply Filter/Sort' from the menu bar to see the record I
    want.

    Any idea what I have done? It appears that the filter information is being
    transferred, but the form is not applying it.

    Thanks

    Nick

  2. #2
    Join Date
    Aug 2002
    Location
    Northampton, England
    Posts
    266
    Can't actually see anything wrong with it. The only thing I would say is that the dot operator should be a bang (!) operator and, are the field names the same in both tables?. If all else fails, delete the command button and create from scratch.

  3. #3
    Join Date
    Mar 2003
    Posts
    11
    Thanks for the reply -

    It seems that I had somehow accidently set the form's data entry property to true... ooops!

    It seems to work now.

    When you say I should use a "!" rather than a ".", I have come accross this before, where both work, but I have been told I am using the wrong one. Is there a rule as to when to use "."'s and "!"'s?

    If they both work, when does it start to cause problems?

    Thanks
    Nick

  4. #4
    Join Date
    Aug 2002
    Location
    Northampton, England
    Posts
    266
    The difference is the ! operator indicates that what follows is a user-defined item (an element of a collection). For example, use the ! operator to refer to an open form, an open report, or a control on an open form or report.

    The . (dot) operator usually indicates that what follows is an item defined by Microsoft Access. For example, use the . (dot) operator to refer to a property of a form, report, or control.

    You may not see any problem, but it one of those insidious little rascals that, if code that has been working perfectly normally up til now, suddenly gives up. In my view, it is better to be safe than sorry later.

    Glad you found the problem.


    David

Posting Permissions

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