Results 1 to 7 of 7
  1. #1
    markjkubicki's Avatar
    markjkubicki is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jul 2010
    Location
    Fire Island Pines, NY
    Posts
    496

    problem calling a form

    (apologies on the round-about to explaination for a probably very simple error..)

    I have a short subroutine that is usually called like this: "CheckForApplicationNote (me)" - it runs fine
    In one instance, from the form which is the usual one that I call the sub from (the "me" form), I open a modal pop-up form.
    When that form closes, I want the sub to run on its close evet, so, I've added the code "CheckForApplicationNote (Forms![frmSpec])", where frmSpec is a valid form (it is acually the name of the usual form that the sub is called from) ---but a I get a datatype mismatch error


    my sub is:

    Public Sub CheckForApplicationNote(frm As Access.Form)
    vStr = "[Manufacturer] = '" & frm.Manufacturer & "' AND [CatalogNumber] = '" & frm.CatalogNo & "'"
    varX = DLookup("[ApplicationNotes]", "FixtureCataloges", vStr)
    vLen = Len(Nz(varX))
    If vLen > 0 Then
    frm.lblHasApplicationNote.Caption = "*"
    Else
    frm.lblHasApplicationNote.Caption = ""
    End If
    End Sub




    Any idea on how I ought to be calling the form would be greatly appreciated
    THANX,

    mark

  2. #2
    Rod is offline Expert
    Windows 7 32bit Access 2007
    Join Date
    Jun 2011
    Location
    Metro Manila, Philippines
    Posts
    679
    Off the top of my head, try

    Forms(frmSpec)

    as the argument.

    Also, do you not get an error by using parentheses when passing the argument; it's a sub procedure.

  3. #3
    markjkubicki's Avatar
    markjkubicki is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jul 2010
    Location
    Fire Island Pines, NY
    Posts
    496
    unfornunately... Forms(frmSpec) did not work

    also about the () with a sub... nope. no error

    thnx,
    Mark

  4. #4
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    I could be wrong, but I believe the Form name has to be enclosed in Double Quotes:

    Forms("frmSpec")

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  5. #5
    Rod is offline Expert
    Windows 7 32bit Access 2007
    Join Date
    Jun 2011
    Location
    Metro Manila, Philippines
    Posts
    679
    Ahhh! Probably right. I assumed frmSpec was a variable containing the name of the form. Doh! Well done.

  6. #6
    markjkubicki's Avatar
    markjkubicki is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jul 2010
    Location
    Fire Island Pines, NY
    Posts
    496
    damn... it's always the obvious...

    thanx!
    that was exactly it

    mark

  7. #7
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Glad we could help!

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Calling a Function From A Form.
    By ksmith in forum Access
    Replies: 2
    Last Post: 06-07-2012, 02:23 PM
  2. Calling a common network file from form
    By lucy1216 in forum Forms
    Replies: 1
    Last Post: 04-23-2012, 09:07 AM
  3. Replies: 2
    Last Post: 10-29-2011, 02:07 AM
  4. Calling up another form - Not Working
    By Buakaw in forum Forms
    Replies: 7
    Last Post: 02-26-2011, 06:49 AM
  5. Calling A Module Function To Open A Form
    By orcinus in forum Modules
    Replies: 3
    Last Post: 09-29-2010, 04:43 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums