473,396 Members | 1,998 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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 "InitialInfoFromSW". 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_AfterUpdate()
Dim cnn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim strSQL As String

'Open a connection to this database file
Set cnn = InitialInfoFromSW.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 2626
"Joanne Lewis" <jl*****@chw.edu> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.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 "InitialInfoFromSW". 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_AfterUpdate()
Dim cnn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim strSQL As String

'Open a connection to this database file
Set cnn = InitialInfoFromSW.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_AfterUpdate()
Me.txtLastname = Me.cboAccount.Column(1)
Me.txtFirstname = Me.cboAccount.Column(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********@sbcglobal.net> wrote in message
news:dF****************@newssvr14.news.prodigy.com ...
"Joanne Lewis" <jl*****@chw.edu> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.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 "InitialInfoFromSW". 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_AfterUpdate()
Dim cnn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim strSQL As String

'Open a connection to this database file
Set cnn = InitialInfoFromSW.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_AfterUpdate()
Me.txtLastname = Me.cboAccount.Column(1)
Me.txtFirstname = Me.cboAccount.Column(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_AfterUpdate()
Me.txtLastname = Me.cboAccount.Column(2)
Me.txtFirstname = Me.cboAccount.Column(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
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...
3
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...
1
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...
2
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...
1
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...
0
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...
3
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...
10
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??? --...
2
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,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.