Results 1 to 6 of 6
  1. #1
    Join Date
    Feb 2006
    Posts
    60

    Unanswered: Update textbox on another form where form+textbox is stored in a textbox!

    I have a little form in my database which is accessed frequently from other forms. The idea behind this is that on the main forms, you need to enter the contact (which could be for a document or a transmittal etc). So when you click the 'to' field, the little form opens up (its a popup + modal) and allows you to look up the contact. then you click a button on the little form, and it should insert the selected contact into the 'to' field you previously clicked in.

    so my method for programing this was to make a global procedure, and when you called that procedure you would enter in its parameters the form+field you want updated. for example
    Code:
    Private Sub txt_To_DblClick(Cancel As Integer)
    Contact_Finder ("Forms![F-Documents]![txt_To].Value")
    End Sub
    Then the procedure would open up the little 'lookup' form, and then enter the form+field parameter into an invisible field for later use.
    Code:
    Sub Contact_Finder(Form_Field)
        DoCmd.OpenForm "F-Contact_Finder"
        Forms![F-Contact_Finder]![txt_Field].Value = Form_Field
    End Sub
    You then select the contact from some combo boxes. Up to this point it all works fine. Its after this when you push the button to update the original field i cant work out what to do. I want to grab the form+field out of the textbox, and then update that field. How can i do this?
    Last edited by neRok; 08-09-07 at 20:53.

  2. #2
    Join Date
    Feb 2006
    Posts
    60
    bump, anyone?

  3. #3
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Nobody appears to have answered so I'll have a go...

    ...I don't really understand the problem / question

    You want to update a controls value based on a value stored in a hidden field on a separate form?
    George
    Home | Blog

  4. #4
    Join Date
    Apr 2004
    Location
    Derbyshire, UK
    Posts
    789
    Provided Answers: 1
    Hi

    I may be baking up the wrong tree (a redwood?), but would this do it.

    Global Procedure
    Code:
    Sub Contact_Finder(byVal ThisFormName as String, ByVal ThisControlName as String, byVal ControlValue as String)
        DoCmd.OpenForm "F-Contact_Finder", , , stLinkCriteria, , ,ThisFormName
        Forms![F-Contact_Finder]![txt_Field].Value = ControlValue
    End Sub
    Opening the form with OpenArgs set as the form name

    and called thus
    Code:
    Private Sub txt_To_DblClick(Cancel As Integer)
    Contact_Finder (Me.name, "txt_To", txt_To)
    End Sub
    Then when you close the F-Contact_Finder form (or after cbo update!) you can update any control on the calling for like this

    Forms(me.OpenArgs).ControlNameToUpdate = cboBoxValue

    or should it be
    Forms(me.OpenArgs).txt_To = cboBoxValue

    ??

    If the control name is different on different forms then that would also have to be passes in then OpenArg and the two parsed ??

    Just some idle thoughts.


    MTB
    Last edited by MikeTheBike; 08-10-07 at 08:58.

  5. #5
    Join Date
    Feb 2006
    Posts
    60
    thanks for your help MTB. i tried a few different things with your suggestions but still could not got my end results, as the control i wanted to update was actually a subform of another form, so it was a bit too complicated.

    i did some searching on google and found a solution written in this book then i changed it a bit to suit me
    http://books.google.com/books?id=NhF...7zoFA#PPA97,M1

    this is the code when double clicking the control
    Code:
    Private Sub txt_To_DblClick(Cancel As Integer)
    
        [To] = Contact_Finder([To])
    
    End Sub
    this is then the function in a module
    Code:
    Function Contact_Finder(Optional Original_Contact)
    
        If IsNull(Original_Contact) Then
            DoCmd.OpenForm "F-Contact_Finder", , , , , acDialog
        Else
            DoCmd.OpenForm "F-Contact_Finder", , , , , acDialog, Original_Contact
        End If
    
        Contact_Finder = Forms("F-Contact_Finder").cmb_Person
        DoCmd.Close acForm, "F-Contact_Finder"
    
    End Function
    this is then the contact finder form code.
    Code:
    Private Sub btn_Use_Contact_Click()
    
        Me.Visible = False
        
    End Sub
    
    Private Sub Form_Open(Cancel As Integer)
    
        cmb_Person = Me.OpenArgs
        
    End Sub

  6. #6
    Join Date
    Apr 2004
    Location
    Derbyshire, UK
    Posts
    789
    Provided Answers: 1
    Hi

    So pleased you found a solution.

    Interesting use of the acDialog argument AND the use of the visible property to restart the code, must bear that in mind, you never know ....

    MTB

Posting Permissions

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