Results 1 to 7 of 7
  1. #1
    bundy75 is offline Novice
    Windows XP Access 2003
    Join Date
    Jul 2010
    Posts
    28

    Set a form record from another form

    I have two forms A and B both of which are open. Form A is the details of a client and form B is a datasheet of all the clients. What I was hoping to do is select a client on form B and then by clicking a button(or double clicking the client if its possible) have form A's record set to the matching client. For reasons I won't go into I don't want to open/reopen form A with the corresponding record but to just set the recod.



    I've tried

    ' Find the record that matches the control.
    Dim rs As Object
    Set rs = Forms!Main_form!Client_Subform.Recordset.Clone
    'Just hardcode a value to see if working
    rs.FindFirst "[Client_Id] = 21"
    If Not rs.EOF Then Forms!Main_form!Client_Subform.Bookmark = rs.Bookmark

    and get the error "Object doesn't support this property or method".

    How should I go about achieving this??????????
    Last edited by bundy75; 09-22-2010 at 02:27 PM.

  2. #2
    NoellaG's Avatar
    NoellaG is offline VIP
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Jun 2010
    Location
    Belgium
    Posts
    1,173
    Hi,

    I don't think Access 2003 already has the "split form" view, which does exactly what you need. You can try simulating this by placing the forms as subforms in a main form.
    As the datasource of the single form you set "Select * from tblX where 1 = 0", so it doesn't open with the first record.
    In the OnCurrent event of the continous subform you can write a code that changes the data source of the single form in something like "select * from tblX where ID = " & nz(me.txtID,0).

    gr
    NG

  3. #3
    bundy75 is offline Novice
    Windows XP Access 2003
    Join Date
    Jul 2010
    Posts
    28
    By datasource do you mean record source??

    This give me the error "The microsoft database engine cannot find the input table or query"

    Is there another way??

  4. #4
    NoellaG's Avatar
    NoellaG is offline VIP
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Jun 2010
    Location
    Belgium
    Posts
    1,173
    Hi bundy,

    of course you have to substitute the table name and filedname in my example by the table /field/control names of the actual table/field/control in your database..

    grNG

  5. #5
    bundy75 is offline Novice
    Windows XP Access 2003
    Join Date
    Jul 2010
    Posts
    28
    Just an update

    Using your idea NoellaG I set the record source to the main_form to "Select * from tblX where 1 = 0" and then linked my single from to it. Now when the button is clicked on the datasheet form I set the main forms recordsource to "Select * from tblX where Id = 21" (hardcoded 21 to test)
    and its working!!!!!

    Just need to find code to get the Id from the form the button is on but problem is fixed - I believe

    Thanks again

  6. #6
    bundy75 is offline Novice
    Windows XP Access 2003
    Join Date
    Jul 2010
    Posts
    28
    Sorry NoellaG just seen your response, I was substituting the correct table names. I think the error was the way I obtain my Id because I am using and mysql server and ODBC driver to access it. But all good now as your idea still works just needed to take it out to main form.

  7. #7
    bundy75 is offline Novice
    Windows XP Access 2003
    Join Date
    Jul 2010
    Posts
    28
    Sorry but I thought this was an easy one but do you know how in VB code to get the value of the id from a the selected row?

    Go it!!!!!!

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

Similar Threads

  1. Replies: 63
    Last Post: 01-25-2013, 05:20 AM
  2. Replies: 6
    Last Post: 07-19-2010, 10:57 AM
  3. Replies: 0
    Last Post: 05-04-2010, 06:39 AM
  4. Replies: 9
    Last Post: 03-24-2009, 09:19 PM
  5. Replies: 0
    Last Post: 11-10-2008, 12:32 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