transfer data from one form to another

krowe

Registered User.
Local time
Yesterday, 16:14
Joined
Mar 29, 2011
Messages
159
Hi All

I have a database which hold customer contact details (amongst other stuff)

I have just brought in a table with all addresses in the area.

I have created a dynamic search form like this: http://www.access-programmers.co.uk/forums/showthread.php?t=188663 to search the address table and would like to now be able to select a result from the SearchResults list box and transfer the details into another form.

To explain more fully, I have a main_form with an address_history sub form. I have a button on the address_history form which has the code goto new record, open FRM_AddressSearch.

I want to then search for an address, double click it, and have the entry copied across to the address fields in the address_history subform.

Hope I have explained this well enough.

Thanks

Kev
 
You can use the OpenArgs property of the OpenForm command to pass the AdressID to the new form and then use the DLookup to pull up all the data related to the AddresID.

The sample here uses OpenArgs to pass data between two forms.
 
Hi
Thanks for your quick reponse.

I'll try that as soon as I get a spare minute.
Kev
 
Hi

I couldn’t get the above solution to work, I’m very novice at this, so trying a different tack now:

I have put code on the PropHistory subform button for 'go to new record and open the address search form':

Code:
DoCmd.GotoRecord , , acNewRec 'new record
 
On Error GoTo Err_Command1_Click
 
    Dim stDocName As String
    Dim stLinkCriteria As String
 
    stDocName = "FRM_SearchAddress"
    DoCmd.OpenForm stDocName, , , stLinkCriteria 'open address search form
'double click on search form does the rest

Then on the address search control I have this code to populate a TempAddress form with all the address info, and then copy the address info into the new record created in the PropHistory form:

Code:
Private Sub SearchResults_DblClick(Cancel As Integer)
 
 
   Dim stDocName As String
   Dim stLinkCriteria As String
 
   stDocName = "FRM_AddressTemp"
    
   stLinkCriteria = "[UPRN]=" & Me![SearchResults]
   DoCmd.OpenForm stDocName, , , stLinkCriteria 'opens Address temp form with selected address filtered
   [Forms]![frmMain].[sformPropHistory].SetFocus 'set focus on prop history
    [Forms]![frmMain].[sformPropHistory].[Form].MovedIn.SetFocus 'go to moved in control
  
 
     Forms!FRM_AddressTemp!ADDRESS_LINE_1 = Forms!frmMain!sformPropHistory.Form!LLPGAdd1 ' copy address line 1
    
    ' etc etc etc
 ' then close Address Temp and Address Search
' set focus on main form
End Sub

Unfortunately it fails at the copy address bit.

Does anyone have any ideas on how I could fix this?


Thanks
 

Users who are viewing this thread

Back
Top Bottom