By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,979 Members | 943 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,979 IT Pros & Developers. It's quick & easy.

How to update form

P: n/a
DK
Please can somebody help me ?

I have forms named Form 1, Form 2 etc. having fields
CustomerName,CustomerAddress,.....

Id like to have button on each form ,which will open another form named
"CustomerAdd" with list of all customers in tblCustomers. After I pick one
of the customers from the list, actual form should be closed and details of
customer shall be send to fields in Form 1 or Form2 or...

Thank You

D
Nov 13 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Br
In news:d4**********@ss405.t-com.hr,
DK <da***********@coxris.hr> said:
Please can somebody help me ?

I have forms named Form 1, Form 2 etc. having fields
CustomerName,CustomerAddress,.....

Id like to have button on each form ,which will open another form
named "CustomerAdd" with list of all customers in tblCustomers. After
I pick one of the customers from the list, actual form should be
closed and details of customer shall be send to fields in Form 1 or
Form2 or...


One method would be to close your first form when opening the second,
and then reopen it when closing the second using the CustomerID in the
Where clause.

(Code is called from OnClose event on your second form)

Docmd.Openform "frmFirstform",,,"[CustomerID] = " & Me![CustomerID]

Another method may be to set the recordsource of your first form using
code when the second is closed.

Forms!frmFirstForm.Recordsource = "SELECT * FROM qryMyQuery WHERE
[CustomerID ] = " & Me![CustomerID]

.... or if your first form contains all customers you can just move to
the selected customer record...

Set myRS as DAO.Recordset
Set myRS = Forms!frmFirstForm.Recordsetclone
myRS.FindFirst "[CustomerID] = " & Me![CustomerID]
If Not myRS.NoMatch Then
Forms!frmFirstForm.Bookmark = myRS.Bookmark
End If
And there are many other variations...

Br@dley
Nov 13 '05 #2

P: n/a
DK
HTNX !
DK
"Br@dley" <n0****@4u.com> wrote in message
news:HL******************@news-server.bigpond.net.au...
In news:d4**********@ss405.t-com.hr,
DK <da***********@coxris.hr> said:
Please can somebody help me ?

I have forms named Form 1, Form 2 etc. having fields
CustomerName,CustomerAddress,.....

Id like to have button on each form ,which will open another form
named "CustomerAdd" with list of all customers in tblCustomers. After
I pick one of the customers from the list, actual form should be
closed and details of customer shall be send to fields in Form 1 or
Form2 or...


One method would be to close your first form when opening the second,
and then reopen it when closing the second using the CustomerID in the
Where clause.

(Code is called from OnClose event on your second form)

Docmd.Openform "frmFirstform",,,"[CustomerID] = " & Me![CustomerID]

Another method may be to set the recordsource of your first form using
code when the second is closed.

Forms!frmFirstForm.Recordsource = "SELECT * FROM qryMyQuery WHERE
[CustomerID ] = " & Me![CustomerID]

... or if your first form contains all customers you can just move to
the selected customer record...

Set myRS as DAO.Recordset
Set myRS = Forms!frmFirstForm.Recordsetclone
myRS.FindFirst "[CustomerID] = " & Me![CustomerID]
If Not myRS.NoMatch Then
Forms!frmFirstForm.Bookmark = myRS.Bookmark
End If
And there are many other variations...

Br@dley

Nov 13 '05 #3

P: n/a
DK wrote:
Please can somebody help me ?

I have forms named Form 1, Form 2 etc. having fields
CustomerName,CustomerAddress,.....

Id like to have button on each form ,which will open another form named
"CustomerAdd" with list of all customers in tblCustomers. After I pick one
of the customers from the list, actual form should be closed and details of
customer shall be send to fields in Form 1 or Form2 or...

Thank You

D

You could pass an argument to the the CustAdd form. Ex:
DoCmd.OpenForm "CustAdd", acNormal, , , ,acDialog,"Form1"

CustAdd now knows which form called it. In the AfterUpdate event of
CustAdd you could do something like
If not IsNull(Me.OpenArgs) Then
Forms(Me.OpenArgs).CustName = Me.CustName
Forms(Me.OpenArgs).CustAddr = Me.CustAddr
Endif

If Form1 is linked to the customer table, you could Requery the form and
then go back to the record.
Dim rst As Recordset
Dim varID As Variant
If Me.OpenArgs = "Form1" Then
varId = Forms!Form1!ID 'the record key
Forms!Form1.form.Requery 'update the table
set rst = Forms!Form1.Form.Recordsetclone
rst.FindFirst "ID = " & varID 'go back to record
Forms!Form1.Form.BookMark = rst.BookMark
rst.Close
Endif
Set rst = Nothing


Nov 13 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.