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

Populate control in another form

P: n/a
My task is to place a button in the form clients,with which to open
the form Customers, go to a new record, and populate this new customer
with the data from the client. This client should be then deleted,
since he is becoming customer already.

With the following code i open the new form,go to a new record, but then
the data are not transferred :
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "FCustomers"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.GoToRecord , "", acNewRec
DoCmd.GoToControl "customerid"
Dim f As Form
Set f = Forms![FCustomers]
f![CompanyName] = Me![CompanyName]
f![City] = Me![city]
f![phone] = Me![phone]
RunCommand acCmdDeleteRecord
Nov 12 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
What _does_ happen? Error messages?

It seems likely that you are trying to work with that form before it
actually opens. I'd suggest you open the form in Data Entry mode and in the
Load, or OnCurrent events of the newly-opened form, obtain the data from the
still-open Client form. Once you have the information, then you can close
the Client form.

As to deleting the Client record, you can do that with a Query from VBA
code -- the Client form does not have to be open.

Larry Linson
Microsoft Access MVP
"Jim Stacey" <og********@yahoo.com> wrote in message
news:9c**************************@posting.google.c om...
My task is to place a button in the form clients,with which to open
the form Customers, go to a new record, and populate this new customer
with the data from the client. This client should be then deleted,
since he is becoming customer already.

With the following code i open the new form,go to a new record, but then
the data are not transferred :
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "FCustomers"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.GoToRecord , "", acNewRec
DoCmd.GoToControl "customerid"
Dim f As Form
Set f = Forms![FCustomers]
f![CompanyName] = Me![CompanyName]
f![City] = Me![city]
f![phone] = Me![phone]
RunCommand acCmdDeleteRecord

Nov 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.