Automatically fill the fields on a form based on COMBO'S VALUE

L

lin

I have a form with fields Name, title, Company,etc..
I set up the Name field as combo for adding makes easier.
When I add new records, if the same person exists in the
table, I would like to fill the fields like title, address
etc.. by automatically .In order to fill the fields
automatically I use the following code.

Private Sub Namecmbo_Click()
Dim vartitle As Variant
vartitle = DLookup
("Title", "Table1", "Name=Form_Table1.Namecmbo]")
If (Not IsNull(vartitle)) Then Me.Title = vartitle
End Sub

This code giving an error previous operation not
cancelled. I don't know what's wrong with this. Any
help.really appreciate.
Thanks.
 
E

Eric Butts [MSFT]

Hi Lin,

I think you maybe going about this the wrong way!!

Take a look at the knowledge base article:

ACC2000: How to Populate Text Boxes with Multicolumn Combo Box Selections
(322900)
http://support.microsoft.com/default.aspx?scid=KB;EN-US;322900


I hope this helps! If you have additional questions on this topic, please
respond back to this posting.


Regards,

Eric Butts
Microsoft Access Support
(e-mail address removed)
"Microsoft Security Announcement: Have you installed the patch for
Microsoft Security Bulletin MS03-026? If not Microsoft strongly advises
you to review the information at the following link regarding Microsoft
Security Bulletin MS03-026
<http://www.microsoft.com/security/security_bulletins/ms03-026.asp> and/or
to visit Windows Update at <http://windowsupdate.microsoft.com/> to install
the patch. Running the SCAN program from the Windows Update site will help
to insure you are current with all security patches, not just MS03-026."

This posting is provided "AS IS" with no warranties, and confers no rights


--------------------
| Content-Class: urn:content-classes:message
| From: "lin" <[email protected]>
| Sender: "lin" <[email protected]>
| Subject: Automatically fill the fields on a form based on COMBO'S VALUE
| Date: Mon, 16 Aug 2004 08:43:43 -0700
| Lines: 42
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Thread-Index: AcSDp89D4lsgQnbbTWW/lD046Z9k3w==
| Newsgroups: microsoft.public.access.gettingstarted
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.access.gettingstarted:153698
| NNTP-Posting-Host: tk2msftngxa13.phx.gbl 10.40.1.165
| X-Tomcat-NG: microsoft.public.access.gettingstarted
|
| I have a form with fields Name, title, Company,etc..
| I set up the Name field as combo for adding makes easier.
| When I add new records, if the same person exists in the
| table, I would like to fill the fields like title, address
| etc.. by automatically .In order to fill the fields
| automatically I use the following code.
|
| Private Sub Namecmbo_Click()
| Dim vartitle As Variant
| vartitle = DLookup
| ("Title", "Table1", "Name=Form_Table1.Namecmbo]")
| If (Not IsNull(vartitle)) Then Me.Title = vartitle
| End Sub
|
| This code giving an error previous operation not
| cancelled. I don't know what's wrong with this. Any
| help.really appreciate.
| Thanks.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top