Results 1 to 5 of 5
  1. #1
    2 Star Lounger
    Join Date
    Apr 2001
    Posts
    122
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Recordsetclone Not Working When Form is AddNew (A2K SP1)

    I have a form that gathers a lot of data in the form of combo boxes and check boxes linked to yes/no fields. After the user completes the form I have code that tests which fields were checked. I define a variable "rst" as a recordset then use the command rst = [Form].Recordsetclone then test the various fields in rst. This works if the form is opened for edit (except that changes made to fields on the form are not recorded) but does not work if the form is opened for Data Entry. When I try to access a field I get the error message "No Current Record."

    How can I define a recordset containing the current information from a form regardless of how the form is opened.

  2. #2
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Recordsetclone Not Working When Form is AddNew (A2K SP1)

    The RecordsetClone is a recordset identical to the recordset behind the form. If you open the form with DataEntry property = Yes, then there are no records in the recordset! Additionally, opening the recordsetclone does not automatically position you at the same record that is current on the screen. YOu have to set the recordsetclone's bookmark = to me.bookmark to get them pointed at same record.

    Anyway, in your case, why are you even worried about the recordsetclone? Just check the controls on the form.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  3. #3
    2 Star Lounger
    Join Date
    Apr 2001
    Posts
    122
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Re: Recordsetclone Not Working When Form is AddNew (A2K SP1)

    The form is actually 2 different forms with overlaping sets of check boxes and both forms exist as versions for data entry and for edit depending on whether the underlying record already exists in the database. Since I have 4 different forms but basically one procedure to check dozens of check boxes, I wanted to create a common procedure called from each form after the user exits the form.

    I have not had success determining the syntax for testing a field on a form from a common procedure, e.g.
    If Forms![Form Name]![Control Name] Then
    works if I specify the actual form name but how do I pass a variable to the common procedure with the name of the actual open form?

  4. #4
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Recordsetclone Not Working When Form is AddNew (A2K SP1)

    You can pass a forms name to the called function like this:
    YourFunction( Me.Name)

    You define YourFunction like this:

    Public Function YourFunction( formname)

    if Forms(formname)![controlname] Then
    ... etc.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  5. #5
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Recordsetclone Not Working When Form is AddNew (A2K SP1)

    Another way, which I prefer, is to pass the form object instead of just its name when you call the function. You do that like this:

    YourFunction Me

    Public Function YourFunction(frm As Form)

    If frm!ControlName = ... etc.

    The advantage is that you don't have to set or destroy a form instance, and the form object carries all its current control and value information along with it.
    Charlotte

Posting Permissions

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