473,748 Members | 4,030 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Auto Fill Form

I am having a great deal of difficulty with a form. Basically, I would
like to enter an account # and have the account #, patient first name,
and patient last name automatically fill.

The form Record Source table is "InitialInfoFro mSW". I want to enter
an account #, have it look in another table called "AS400 Imported
Data", and automatically fill in the fields called "LastName" and
"FirstName" into the form's text boxes.

It was suggested to me to use a combo box's AfterUpdate event in the
form header to open a recorset from the AS400... table. This is the
code (that I cannot get to work correctly....):

Option Compare Database
Option Explicit

Private Sub cboAccount_Afte rUpdate()
Dim cnn As ADODB.Connectio n
Dim rs As ADODB.Recordset
Dim strSQL As String

'Open a connection to this database file
Set cnn = InitialInfoFrom SW.Connection

'Open a recordset with the selected Account
Set rs = New ADODB.Recordset
strSQL = "SELECT * FROM [AS400 Imported Data]" _
& "WHERE Account='" & Me.cboAccount & "'"
rs.Open strSQL, cnn, adOpenStatic

'Fill the textboxes with the info in the recordset.
Me.txtAccount = rs!Account
Me.txtLastName = rs!LastName
Me.txtFirstName = rs!FirstName

'Clear the objects from memory.
Set rs = Nothing
Set cnn = Nothing
End Sub
I would be extremely grateful for any help!!

Joanne

Nov 13 '05 #1
2 2657
"Joanne Lewis" <jl*****@chw.ed u> wrote in message
news:11******** **************@ z14g2000cwz.goo glegroups.com.. .
I am having a great deal of difficulty with a form. Basically, I would
like to enter an account # and have the account #, patient first name,
and patient last name automatically fill.

The form Record Source table is "InitialInfoFro mSW". I want to enter
an account #, have it look in another table called "AS400 Imported
Data", and automatically fill in the fields called "LastName" and
"FirstName" into the form's text boxes.

It was suggested to me to use a combo box's AfterUpdate event in the
form header to open a recorset from the AS400... table. This is the
code (that I cannot get to work correctly....):

Option Compare Database
Option Explicit

Private Sub cboAccount_Afte rUpdate()
Dim cnn As ADODB.Connectio n
Dim rs As ADODB.Recordset
Dim strSQL As String

'Open a connection to this database file
Set cnn = InitialInfoFrom SW.Connection

'Open a recordset with the selected Account
Set rs = New ADODB.Recordset
strSQL = "SELECT * FROM [AS400 Imported Data]" _
& "WHERE Account='" & Me.cboAccount & "'"
rs.Open strSQL, cnn, adOpenStatic

'Fill the textboxes with the info in the recordset.
Me.txtAccount = rs!Account
Me.txtLastName = rs!LastName
Me.txtFirstName = rs!FirstName

'Clear the objects from memory.
Set rs = Nothing
Set cnn = Nothing
End Sub

I would be extremely grateful for any help!!
Joanne

----------------------------------------------------------------

Joanne,
I think you have over-complicated the process.
If your combobox, cboAccount, has the following 3 columns:
Account
Lastname
Firstname

Then your only code needs to be:

Private Sub cboAccount_Afte rUpdate()
Me.txtLastname = Me.cboAccount.C olumn(1)
Me.txtFirstname = Me.cboAccount.C olumn(2)
End Sub

Also, you don't need the control named txtAccount. Just use the control
named cboAccount.

I Hope That Helps,
Fred Zuckerman

Nov 13 '05 #2
"Fred Zuckerman" <Zu********@sbc global.net> wrote in message
news:dF******** ********@newssv r14.news.prodig y.com...
"Joanne Lewis" <jl*****@chw.ed u> wrote in message
news:11******** **************@ z14g2000cwz.goo glegroups.com.. .
I am having a great deal of difficulty with a form. Basically, I would
like to enter an account # and have the account #, patient first name,
and patient last name automatically fill.

The form Record Source table is "InitialInfoFro mSW". I want to enter
an account #, have it look in another table called "AS400 Imported
Data", and automatically fill in the fields called "LastName" and
"FirstName" into the form's text boxes.

It was suggested to me to use a combo box's AfterUpdate event in the
form header to open a recorset from the AS400... table. This is the
code (that I cannot get to work correctly....):

Option Compare Database
Option Explicit

Private Sub cboAccount_Afte rUpdate()
Dim cnn As ADODB.Connectio n
Dim rs As ADODB.Recordset
Dim strSQL As String

'Open a connection to this database file
Set cnn = InitialInfoFrom SW.Connection

'Open a recordset with the selected Account
Set rs = New ADODB.Recordset
strSQL = "SELECT * FROM [AS400 Imported Data]" _
& "WHERE Account='" & Me.cboAccount & "'"
rs.Open strSQL, cnn, adOpenStatic

'Fill the textboxes with the info in the recordset.
Me.txtAccount = rs!Account
Me.txtLastName = rs!LastName
Me.txtFirstName = rs!FirstName

'Clear the objects from memory.
Set rs = Nothing
Set cnn = Nothing
End Sub

I would be extremely grateful for any help!!
Joanne

----------------------------------------------------------------

Joanne,
I think you have over-complicated the process.
If your combobox, cboAccount, has the following 3 columns:
Account
Lastname
Firstname

Then your only code needs to be:

Private Sub cboAccount_Afte rUpdate()
Me.txtLastname = Me.cboAccount.C olumn(1)
Me.txtFirstname = Me.cboAccount.C olumn(2)
End Sub

Also, you don't need the control named txtAccount. Just use the control
named cboAccount.

I Hope That Helps,
Fred Zuckerman

+Hi Fred,
+Thanks for your help. I tried this, but it still is not working....
+Maybe I'm doing something else wrong. The combobox in the form header
+is unbound; the row source is:
+
+SELECT DISTINCTROW [AS400 Imported Data].[ID], [AS400 Imported
+Data].[Account], [AS400 Imported Data].[LastName], [AS400 Imported
+Data].[FirstName] FROM [AS400 Imported Data];
+
+The Account, Lastname, Firstname are just text boxes in the detail
+section.
+
+Am I missing something?
+
+Thanks for your help!!!!!
+
+Joanne
+

Joanne,
Please reply to the group. Others may have the same questions and could
learn from the responses.

It looks like your combo box has the following columns:
ID
Account
Lastname
Firstname

So the code would be:

Private Sub cboAccount_Afte rUpdate()
Me.txtLastname = Me.cboAccount.C olumn(2)
Me.txtFirstname = Me.cboAccount.C olumn(3)
End Sub

The combo box may need to be in the detail section, too.

Fred
Nov 13 '05 #3

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

Similar topics

1
2375
by: Maurice Mertens | last post by:
Does anyone know how to get an auto-filling combobox on a form? When I add a combobox to a form I can set the DropDownStyle property to DropDownList. This will make the combobox auto-filling. But the user then can't enter text in the combobox which isn't in the list. So I have to set the DropDownStyle property to DropDown to enable the user to enter text which isn't in the list. But unfortunately the combobox doesn't auto-fill the text...
3
2370
by: MatGyver | last post by:
I am going nuts trying to figure this out, any help will be appreciated. I have an existing table called "Parts". And in this table I have the following columns: "ID" "Part Number" "Part Description" "Part Cost" I am trying to build an order form that will have "Part Number" and "Part Cost" both on the form and in that forms specific table.
1
668
by: Benny | last post by:
Hello experts, Currently I am working on a web application using vs.net with c#. One of the project task is creating invoices. After the invoices are created, the user needs login to a government website and enter the same invoice information again. Since the information entered to the government website are the same as
2
2462
by: big_boy | last post by:
i am working with access 2000. i have a form that when you feel it out, it stores the information in the table for the form. am trying to write a auto fill query for it to automatically fill the rest of the information when the name matches the one already there......help
1
4139
by: qwas2123 | last post by:
Hi, Im trying to build a form that within the form it has a feature that if you input data into a certain text box, from there, it will automatically fill the rest of the text boxes on the form based on the information of specific tables. Example : ID___________ Name "auto" ____________ Loc "auto" ____________ Rank "auto" ____________ etc . . . I...
0
2695
by: KelHemp | last post by:
Greetings, I've been using this site for lots of access help in the past, and it's very helpful! I have a new complexity for you all. Reworking a form to record 70-80 years of oil production on multiple leases, which have multiple wells within them. Most wells can fit on one printed page (one record), but in the case of overspill, we want to do the following: -Move to a new record and auto fill the LeaseName, LeaseNumber, Operator,...
3
3095
by: Steve67 | last post by:
I didn't see a search feature in these forums, so I couldn't look up this question and I am sure it is a common questions. I am trying to auto fill some information on an form. Here is what I have going on. I created a form that will fill in information on one table, but I also want information from another table on this form, but I want this infomation to automatically fill in was soon as I type lets say a part number. I tried to do this by...
10
2549
by: Charles Richmond | last post by:
Is there some parameter I can set via Javascript that will cause the browser to *not* auto-fill forms, regardless of the browser settings??? -- +----------------------------------------------------------------+ | Charles and Francis Richmond richmond at plano dot net | +----------------------------------------------------------------+
2
4742
by: paulyXvpf | last post by:
Hi All, FACTS: > I've created a VB.NET 2005 form, with a SQL Server 2000 backend > The form has about 30 fields that populate 30 columns in the SQL database > The form has mostly text feilds, with standard info such as Customer, order Number, etc. > Im trying to autopopulate one of the feilds on the form, called Reference Number. > The SQL column on the backend auto increments fine > The Reference Numbercolumn has identity...
0
8831
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
9548
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9374
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...
0
9249
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
4607
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
4876
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3315
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2787
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2215
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.