Programatically Filling 2 Text Boxes

B

Brennan

Hello:

I have a main form named Statements and a Subform name
Statement Details that sits on the main form. There is a
combo box called Accounts that provides a list of
accounts that the user can choose from to add to a
statement. The combo box references tha Accounts table
to get it's values.

There are 2 additional fields in the statement detail
subform called Account Number and Amount. These are also
fields that are present in the Accounts table.

What I would like to accomplish is to programtically
update these 2 fields using the respective values from
the Accounts table after the user selects an account
using the Accounts combo box.

I tried using the following code in the AfterUpdate
property of the Accounts comboc box but it didn't work:

Private Sub Contractor_AfterUpdate()
Dim sSQL As String
sSQL = "Select tblAccounts_AccountID,
tblAccounts_AccountNum from tblAccounts
where " & "tblAccounts_AccountID=" & Me!AccountID
AccountNum = sSQL
End Sub

Any suggestions would be appreciated

Thanks,
Brennan
 
J

Jonathan Parminter

Hi Brennan,
in the properties of the combobox:
1. add the two fields (Account Number and Amount). click
the build button (...).
2. add 2 to the column count.
3. add 2 widths to the column width property. Use 0;0 if
users don't need to see these columns when making a
selection.
4. in the combobox_afterupdate() use the combobox column
property to access these field values... for example when
the combobox has 3 fields (Accounts;Account Number;Amount):
txtAccountNumber = combobox.column(1)
txtAmount = combobox.column(2)

luck
Jonathan
 
B

Brennan

Thanks

This solution worked perfectly


Brennan

-----Original Message-----
Hi Brennan,
in the properties of the combobox:
1. add the two fields (Account Number and Amount). click
the build button (...).
2. add 2 to the column count.
3. add 2 widths to the column width property. Use 0;0 if
users don't need to see these columns when making a
selection.
4. in the combobox_afterupdate() use the combobox column
property to access these field values... for example when
the combobox has 3 fields (Accounts;Account Number;Amount):
txtAccountNumber = combobox.column(1)
txtAmount = combobox.column(2)

luck
Jonathan

.
 

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