Results 1 to 8 of 8
  1. #1
    Join Date
    Nov 2003
    Location
    Europe
    Posts
    369

    Question Unanswered: Setting a form's record source: "Object doesn't support this property or method"

    I have a form with two subforms on it. No parent-child relationships. The first subform is based on a union query, and when I click on a check box in one of the records, I want to set the recordsource for the other subform to the one I click on.

    When I try to refer to the other subform like this:
    Forms!subfrmX.RecordSource = "(Select xxxx....

    - then i get a message about that the form cannot be found. I guess that is because it is not open as itself, but as a subform within the parent form of the first one...

    So, I try to specify the main form along with it like this:
    Forms!frmMain.subfrmX.RecordSource = "(Select xxxx....

    When I check the values as they change during code execution, it is obvous that the form is now found, but I then get a different error:
    "Object doesn't support this property or method".

    What does that mean?

    PS. I am first assigning the ID to a global variable, gid_sell, and the where clause in the select statement looks like this:

    WHERE tbl_sell.ID_sell=)" + CStr(gid_sell)

    when I point to the gid_sell public/global variable at the end of this statement during execution, the correct id value is displayed as a "tooltip"and hence obviously set. However, I am not sure if the error can be related to the way I close the select statement and then include the variable pointer:
    " + CStr(gid_sell)

    this does not work either:
    =)" & variable
    ( =)" & gid_sell )

    I have changed the reference to the following:

    Forms![Mainform].[subfrmX].RecordSource = "(Select xxxx....
    ... WHERE tbl_sell.ID_sell=)" + CStr(gid_sell)

    But that produces the same error...
    Last edited by kedaniel; 02-04-04 at 09:50.

  2. #2
    Join Date
    Nov 2003
    Location
    Europe
    Posts
    369

    Question Re: Setting a form's record source: "Object doesn't support this property or method"

    Originally posted by kedaniel
    Forms!subfrmX.RecordSource = "(Select xxxx....

    So, I try to specify the main form along with it like this:
    Forms!frmMain.subfrmX.RecordSource = "(Select xxxx....

    WHERE tbl_sell.ID_sell=)" + CStr(gid_sell)

    Forms![Mainform].[subfrmX].RecordSource = "(Select xxxx....
    ... WHERE tbl_sell.ID_sell=)" + CStr(gid_sell)

    But that produces the same error...

    UPDATE:
    The following variations after enclosing in brackets:

    ...].Form!Recordsource = ..., produces this error:
    "Microsoft Access can't find the field
    'RecordSource' referred to in your expression."

    and
    ...].Form.RecordSource = ..., produces this error:

    "Syntax error in union query."

    Now that is more specific, but the form targeted does not have a union query, I am indeed trying to set its record source..., and the unbound option button / could be a check box as well) that I click on in the first subform to select the actual record and send it to the subform in question, IS based on a union query, hence read-only, and it beeps when I click on the option button. BUT i manage to open a form when clicking on it (tested with "any" form, so I still think it is not about a union query syntax error, but something wrong in the reference.

  3. #3
    Join Date
    Oct 2001
    Location
    Chicago
    Posts
    440
    Forms!frmMain!subfrmX.Form.RecordSource = "(Select xxxx....
    from tbl_sell where tbl_sell.ID=" & gid_sell & ")"

    (where subfrmX is the name of the subform control and not the subform itself - wizard creates the contol using the same name)


    --------------------------------------


    >Forms!frmMain.subfrmX.RecordSource = "(Select xxxx....

    Forms!frmMain.subfrmX. <-- missing 'Form' here


    --------------------------------------


    >WHERE tbl_sell.ID_sell=)" + CStr(gid_sell)

    WHERE tbl_sell.ID_sell=) <--- incorrect
    incorrect --->CStr(gid_sell) - keep numeric if id is numeric

  4. #4
    Join Date
    Nov 2003
    Location
    Europe
    Posts
    369

    Thumbs up Thanks, that works :)

    Have to memorize this, not the first time I am confused about the usage of brackets vs. periods vs. exclamation signs. ..

    Thanks

  5. #5
    Join Date
    Nov 2003
    Location
    Europe
    Posts
    369

    Question Further: record locking issue

    OK, so now I get the desired record up in the second subform.

    When trying to update/save the record in the new form, I get the message "The command or action "SaveRecord" isn't available now". Record locking issue. Either the focus is still on that record in the above form where I "got it from"/clicked on it, or that that subform's underlying union query - or the subform itself is locking the record.

    I have checked both Subform properties, and the first one is set to No locks, the one I want to save in is set to Lock Edited Record. I have turned off Add/Delete etc. in the first one, but in order to be able to click on each record in its datasheet view (clicking the option button is the action that sends the record to the other subform), it seems to be necessary to Allow Edits...?

    Is it the underlying union query that locks the record? The whole record set? Can I run such a query read-only? I have set the query's Record Locks property to No Locks, and also just now tried to moved the routine that brings the record up in the other sub form away from the click event of the option control to its GotFocus event, so that I can set Allow Edits to No, and still get to click on the option button to trigger the event, but I get the same message, seems that the record is locked...

    Any thoughts?

  6. #6
    Join Date
    Nov 2003
    Location
    Europe
    Posts
    369

    Angry Re: Further: record locking issue

    Hm. Quite strange: after the message abuout not having SaveRecord available, the update has still happened: I can enter a new record and try to go back to the one on which I got the error message, and the update has indeed been saved..!

  7. #7
    Join Date
    Oct 2001
    Location
    Chicago
    Posts
    440
    You can not update a Union query. Not sure how you are laying out each form/subform or which form you edited, but that is why you get that message.

  8. #8
    Join Date
    Nov 2003
    Location
    Europe
    Posts
    369

    Arrow

    Originally posted by Rockey
    You can not update a Union query. Not sure how you are laying out each form/subform or which form you edited, but that is why you get that message.
    Not so simple:
    One main form with two subforms on it. None of them are linked parent/child wise.

    The first (topmost) subform is the one based on a union query. Its role is simply to let the user conveniently click on any record in the list (datasheet view) to have it open editable in the second subform, by resetting the second subform's record source to a simple query to one of the two main tables, by fetching the Sales or Purchase ID from the union query.

    The subform with the union query is read-only, I have added an unbound option control that appears as the first column in that subform. On either its OnClick or Gotfocus events, it fetches the ID from the record being clicked on, and passes is as a parametre (through a global variable) to a select query that then is being used as the second subform's record source.

    I created the second sub form in the first place based on the very union query, but have now changed its record source. I wonder if there can be another place where that subform still has a link to its original base..?

Posting Permissions

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