Results 1 to 6 of 6
  1. #1
    Middlemarch is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Mar 2015
    Posts
    479

    Defining With Object

    I'm attempting to pass the current record (or Me) from a Forms GotFocus event to a function in a module,
    Code:
    Public Function PrefixSet(xForm As ???) As Boolean
        With xForm
        ...
        End With
    End Function
    And get the contents of the various fields in the dropdown list inside With-End With (that opens with ".")

    Initially I'm getting error With object must be user-defined type, Object, or Variant but suspect that's only the beginning of what I might have wrong.

    What should I put for ???
    I tried Object but noluck...

    Thanks.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    There no need to pass a form as a param. If you have it open, just reference it.

    With forms!frmMain

    end with.

    but I wouldn't use the WITH structure...just the full path for each object.
    forms!frmMain!txtBox= 23

  3. #3
    Middlemarch is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Mar 2015
    Posts
    479
    Ok, thanks... but what if you had several Forms that you wanted to use in the same function ?
    Is the use of With discouraged in Access ?

    Addressing of forms is confusing, I've been using Form_frmMain.xxxx because then I can see the choices. Is that not Ok

  4. #4
    CJ_London is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,840
    use

    xForm As Form

  5. #5
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    You don't pass the form, you pass the values in the form...

    txtbox = PrefixSet(txtName, txtAddress)

  6. #6
    Middlemarch is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Mar 2015
    Posts
    479
    Passing "as Form" doesn't raise an error but doesn't show the current record fields with "." dropdownlist. (What is the right name for that ?)

    Ranman256, I don't get what you mean at all, sorry.

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

Similar Threads

  1. Defining an Array in an Access Table
    By EddieN1 in forum Database Design
    Replies: 9
    Last Post: 10-10-2014, 08:09 AM
  2. Need help defining the relationship
    By ewong in forum Access
    Replies: 16
    Last Post: 08-27-2012, 05:48 PM
  3. Replies: 10
    Last Post: 09-29-2011, 11:39 AM
  4. defining and setting value of a varible?
    By meet_binay in forum Queries
    Replies: 5
    Last Post: 01-17-2011, 03:50 PM
  5. defining Criteria between two dates
    By tamu46 in forum Queries
    Replies: 1
    Last Post: 12-04-2010, 11:58 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