Results 1 to 5 of 5

Thread: still stuck

  1. #1
    Join Date
    Jul 2003
    Posts
    42

    Unanswered: still stuck

    I have what seems like a simple problem but cant get it to work.
    For ease of explaination lets just use the names as follows:

    AddRequestor Combobox: RBox
    Add Requestor Button: RBtn
    Add Requestor BoundForm (to Requestor Table): RF
    Requestor Table:RT
    Requestor ID: RID
    Mainform Table: TA
    Mainform Record No: MID
    Mainform: MF

    I have an AddRequestor button "Rbtn" on the Mainform that takes the user to a bound form "RF" where they can add a requestor to the Requestor table "RT".

    I need the new entry to come back to the Mainform Combo box "Rbox" and send that selection to the Main table "TA" for record no. "ID".

    I tried an earlier suggestion from Izzy but the code wasnt working.

  2. #2
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    suitably refreshed after a short vacation and many fine english ales...

    what didn't work?
    did the unbound add-requestor form add a requestor?
    did the combo switch to the new requestor? ...and if not, did the .requery allow you to manually select the new Requestor.

    tagging this stuff into a second table either wasn't in the original brief or i overlooked it.

    izy

  3. #3
    Join Date
    Jul 2003
    Posts
    42

    here goes

    A while back you went over the combo box and an unbound form selection which pulls the data back over to the mainform.

    I think I am missing a second step here:

    Theres a button on the main table which does this:

    private sub Command271_Click()
    dim dabs as dao.database
    dim recs a dao.recordset
    dim imHere as long
    set dabs = currentdb
    set recs = dabs.openrecordset("04-ReqList ")

    There must be a second step to this part..is there a button on the unbound form for this part or does it do this on open? I cant see how it could all be one macro because you need a way to get from main form to the unbound one and back again. This is the second part.

    recs.addnew
    recs! LF-FN = [LNFN].value
    imHere = recs!RQID
    recs.update

    This looks like a third piece once you get back to the main form.

    forms![00_02-CRWorksheet]![RequestorBox].requery
    forms![00_02-CRWorksheet]![RequestorBox].value = imHere
    end sub

    I tried putting the Open Form button on the mainform as an open to the unbound form. Then I put the button with the code on the unbound form. Theres a FIBbox & Button with this code right now but it doesnt like some of the text:

    private sub Command271_Click()

    dim dabs as dao.database

    dim recs a dao.recordset
    - Didnt work, so I tried "dim recs AS dao.recordset" and it did work, not sure if that will give me the same result -

    dim imHere as long

    set dabs = currentdb

    set recs = dabs.openrecordset("04-ReqList")

    recs.addnew

    recs! LNFN = [LNFN].value
    -It died from here out one. Not sure what I am doing wrong. The box to enter into on the unbound form is called "LNFN", the field in the [04-Reqlist table] to give the value to is "LNFN" as well to make it simple.

    (Dont know about the below items yet until I get the above error corrected.)

    imHere = recs!RQID

    recs.update

    forms![00_02-CRWorksheet]![RequestorBox].requery

    forms![00_02-CRWorksheet]![RequestorBox].value = imHere

    end sub

  4. #4
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    on the main form you have some sort of button "add a new requestor".

    this button opens your add-requestor form (unbound)(pop-up/modal?).
    here your gallant user enters all the stuff associated with the new requestor in stuff1box, stuff2box, stuff3box etc.
    there is NO id box for the user to play with because this is going to be an autonumber (right?)

    your add-requestor form has cancel & doIt buttons. cancel just closes the form, but in your add-requestor form module:
    Code:
    private sub doIt_Click()
      dim dabs as dao.database
      dim recs as dao.recordset 'a typo
      dim imHere as long
    
      'here you maybe check that your happy user 
      'hasn't entered something stupid in the boxes
    
      set dabs = currentdb
      set recs = dabs.openrecordset("04-ReqList ") 'if that is your requestor table
        recs.addnew 'triggers the new autonumber id
        recs!stuff1field = stuff1box.value ' there is no SPACE after "!"
        recs!stuff2field = stuff2box.value 'and so on
        recs!stuff3field = stuff3box.value
     
        'grab the id of the new requestor
        imHere = recs!RQID
     
        recs.update 'equivalent to clicking the pencil in table-view
    
      'as of now, your new requestor exists in table 04-ReqList
      'with id = imHere
    
      'now you need to get this new entry fed into your combo on the
      'main form: the recordset in this combo is out of date:
      forms![00_02-CRWorksheet]![RequestorBox].requery
      'ought to do the trick
    
      'next, get the combo to show the new requestor:
      forms![00_02-CRWorksheet]![RequestorBox].value = imHere
      'should work IF the bound column in your combo is RQID
      'if still stuck, comment out the second line of this para and see
      'if you can manually select the new requestor in the combo
    
      'tidy up
      set recs = nothing
      set dabs = nothing
      docmd.close acForm, "whateverYourAddRequestorFormIsCalled"
    
    end sub
    izy
    Last edited by izyrider; 08-06-03 at 07:36.

  5. #5
    Join Date
    Jul 2003
    Posts
    42

    worked like a charm

    This worked perfectly Izzy. Thank you so much!

Posting Permissions

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