473,800 Members | 2,726 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

drop list to fill in the blanks on a form

i want to create a form where the user can choose from a list of names
in table A

associated with this name is a telephone and address

on the form there will be a drop list for the name, fields for address
and telephone and a comment section

i would like the form to fill in the address and telephone
automatically once the name is chosen, (the only field the user can
actually enter anything into is the comment section) the information in
the form will be saved to table B

getting it to select the name from table A is easy, but how do I get it
to automatically enter the associated information for the other 2
fields

thanks

Feb 27 '06 #1
8 2977
Firstly, you might not want too! Access being a relational database
means that you only need to reference the full details but show them
in, for example, a child / parent record.

Or if you actually want to do what you ask, have a combo box with the
name as the first column(0) and then have the next coluns for the other
data, address and so on. Then use the after update event for the combo
to populate the other boxes from the combo:

Private Sub cmbContact_Afte rUpdate()

Me.ContactName = Me.cmbContact.C olumn(0)
Me.ContactAddre ss1 = Me.cmbContact.C olumn(1)
Me.ContactAddre ss2 = Me.cmbContact.C olumn(2)
Me.ContactPhone = Me.cmbContact.C olumn(3)

'and so on..........

Jon

Feb 27 '06 #2
this gives me something to chew on, i'll give it a try tomorrow

thanks

Feb 28 '06 #3
I gave it a try and I keep getting the following error message:

run time error '2135':
this property is read only and can't be set

not sure what is going on but I think I'm on the right track now

Mar 1 '06 #4
I figured out what was happening, I was using "Name" for one of boxes,
once i changed it to something else (Client) the errors stopped.

Thanks again.

Mar 1 '06 #5
"cwhite" wrote
I figured out what was happening, I was using
"Name" for one of boxes, once i changed it to
something else (Client) the errors stopped.


Quite predictably and quite intuitively, you cannot have two objects in the
same scope with the same name.

Not quite so predictably but intuitively once you think about it, you should
not be using "Name" as the name of anything, e.g., Field in a Record, or
Control on a Form or Report, or any Access object? Why not? Because Name is
an Access reserved word... many objects have a "Name" property and it isn't
always possible for Access to determine from context whether you intend to
use the object you have named "Name" or Access' property named "Name".

That's one of the reasons you find people following some naming conventions
that may appear strange to you -- Access has no reserved words that begin
with "txt" or "cbo", for example.

Larry Linson
Microsoft Access MVP

Mar 6 '06 #6
I've noticed something odd about the form I created with your
assistance.

It selects and enters the information into the boxes just fine, however
it seems to automatically save whatever is selected.

The second you exit the form it saves the info, if you select a
different person becuase the first one was wrong, it will save the
first one., If you start to make a change to the selected client it
will save the information.

I've never created a form that pulls info from one table and puts it in
another before so I think I am missing something. Normally I would
make a save, clear and exit buttons and they would function properly,
but it won't work with this form.

here are the codes for the button and selection:

Private Sub cmbClient_After Update()

Me.Client = Me.cmbClient.Co lumn(0)
Me.SIN = Me.cmbClient.Co lumn(1)
Me.Telephone = Me.cmbClient.Co lumn(2)
Me.Location = Me.cmbClient.Co lumn(3)
Me.Counsellor = Me.cmbClient.Co lumn(4)

End Sub
Private Sub Save_Btn_Click( )
On Error GoTo Err_Save_Btn_Cl ick
DoCmd.DoMenuIte m acFormBar, acRecordsMenu, acSaveRecord, ,
acMenuVer70
DoCmd.GoToRecor d , , acNewRec

Exit_Save_Btn_C lick:
Exit Sub

Err_Save_Btn_Cl ick:
MsgBox Err.Description
Resume Exit_Save_Btn_C lick

End Sub
Private Sub Clear_Btn_Click ()
On Error GoTo Err_Clear_Btn_C lick
DoCmd.GoToRecor d , , acNewRec

Exit_Clear_Btn_ Click:
Exit Sub

Err_Clear_Btn_C lick:
MsgBox Err.Description
Resume Exit_Clear_Btn_ Click

End Sub
Private Sub Exit_Btn_Click( )
On Error GoTo Err_Exit_Btn_Cl ick
DoCmd.Close

Exit_Exit_Btn_C lick:
Exit Sub

Err_Exit_Btn_Cl ick:
MsgBox Err.Description
Resume Exit_Exit_Btn_C lick

End Sub

the problem has to be with the combo box but I don't know what it is.

Any help/ideas would be greatly appreciated.

Thanks

Mar 8 '06 #7
It is saving the data because the fields (Client; Sin and so on) have
now got data (or the data has changed), they will be saved by default
when you leave the record. If you don't want to save the data anywhere
then use an unbound field

Me.Text1.Text = Me.cmbClient.Co lumn(0)

Jon

Mar 11 '06 #8
thanks for all of your input, I haven't been back to that particular
location yet so I haven't had a chance to give it a try

I'll let you know how it works out, but I don't forsee any problems

Thanks!!!

Mar 20 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1782
by: owyn | last post by:
Think of a Drop Down List in a template column in a data grid in the Edit Template. In the Item template there is a label whose: text = '<%# DataBinder.Eval(Container.DataItem, "FieldName")%>' The FieldName comes from the table that the data grid is bound. What would be neat would be to be able to fill the Data Value Field and the Data Text Field of that Drop Down List from a pick list that is passed as a data table form a class. In other...
1
2913
by: Dan | last post by:
This is one that has me stumped and I need an expert's input. Any ideas why the values from the second script-generated drop down list isn't recognized by the script to add time values to the text boxes? What this script is suppose to do is change the value of a second drop down list based on the selection from the first. Then a value is chosen from the script generated drop down list in the
5
2305
by: keith | last post by:
This may seem simple, but I'm having a bit of trouble figuring out exactly how to do it. I'm accessing a database through an ODBC link, and I have a query that returns only jobs completed that day (it's automatically generated). 1 user may finish 10, 20, or 50 jobs a day, but there can be at least 20-50 users per day, and they're always going to be different. The users aren't going to return, or if they do, it's always going to be under...
2
2380
by: ramesh | last post by:
hi, I am using Com+ in my application. It will have InsertRecords,selectRecords,updateRecords function. In the Web Form i have Drop-down list. I want to select records from SQL and add it to this list. I know how to fill the data in the drop-down list. But i don't know how to pass this control to Com+. Do we need to pass like private FillList(Object e) {
0
1738
by: Giulio Santorini | last post by:
Hi, I've got two drop down list controls. When I select a value from the first one I fill the second one. And when I select a value from the second one I would like to fill another control. But after have choose from the first control and filled the second... when I select something from the second control I have not the post back event! I hope to be understandable! I've attached the code that make problems. It's commented in italian so...
3
26337
by: Stephen Adam | last post by:
Hi there, I'm sure i'm missing something really simple here, all i want to do is get the value of the selected item in a list box. Even after much fiddling about last night I still could not get my code to work. Below is some code which highlights my problem. All I want to do is set the lable control's text property to the value of the selected drop down list value - in this example i've shown the three ways i've tried. Please help!
3
2058
by: pmud | last post by:
Hi, I have 2 drop down lists on an asp.Net page. The 1st contains alphabets. When the user selects an alphabet frm the first list, the second drop down list should be populated with names from the sql database, which begin with that alphabet. For this I used an sql data Adapter & created a data set. The user's selection in 1st list is passed as parameter to the sql statement.
2
6931
by: kalaivanan | last post by:
hi, i am developing web application using c#. in a particular page i am using two drop down list boxes, one for product and the other for corresponding models of a product. whenever i select a product the corresponding models will be populated in the model drop down list. and i am using ajax for populating the model ddl. hence the model ddl will be populated at the client. now when i do my processing using the datum in the page i am...
3
1900
by: Hanoodah | last post by:
Good morning all, Please I need help in a form that I have designed to fill user information. This form needs two drop-down list about specific date, one about contract date, and the other about birth date. I am using java script function to display the dates, and use onload() function to set the drop-down list to the current date. I following error used to appear (null or not an object)!! Can any one help me in that? The code: ...
0
9691
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9551
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10279
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10255
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10036
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6815
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5473
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5607
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2948
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.