Populating Unbound Fields

  • Thread starter Thread starter DS
  • Start date Start date
D

DS

Is there a way to populate Unbound Textboxes on an Unbound Form based on
a CustomerID without using a number of DLookUps?
These are the fields
Me.TxtBusinessName
Me.TxtDeeName
Me.TxtAddress
Me.TxtApt
Me.TxtCity
Me.TxtState
Me.TxtZipCode
Me.TxtTel
Me.TxtExt
Me.TxtFax
Me.TxtEMail
Me.TxtCreditLimit
Me.ChkHouseAccount
They are all from one table called Customers.
Thanks
DS
 
DS said:
Is there a way to populate Unbound Textboxes on an Unbound Form based on
a CustomerID without using a number of DLookUps?
These are the fields
Me.TxtBusinessName
Me.TxtDeeName
Me.TxtAddress
Me.TxtApt
Me.TxtCity
Me.TxtState
Me.TxtZipCode
Me.TxtTel
Me.TxtExt
Me.TxtFax
Me.TxtEMail
Me.TxtCreditLimit
Me.ChkHouseAccount
They are all from one table called Customers.
Thanks
DS
Ok This almost works...
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("SELECT * FROM Customers WHERE
Customers.CustomerID = " & Me.TxtCusID & "", dbOpenDynaset)
With rst
Do Until .EOF
Me.TxtBusinessName = !BusinessName
Me.TxtDeeName = !FName& "" "" &!LName
Me.TxtAddress = !Address
Me.TxtApt = !Apt
Me.TxtCity = !City
Me.TxtState = !State
Me.TxtZipCode = !ZipCode
Me.TxtTel = !Tel
Me.TxtExt = !Ext
Me.TxtFax = !Fax
Me.TxtEMail = !EMail
Me.TxtCreditLimit = !CreditLimit
Me.ChkHouseAccount = !HouseAccount
.MoveNext
Loop
End With
rst.Close
Set rst = Nothing
dbs.Close
Set dbs = Nothing

The problem is TxtDeeName which combines 2 fields...it works until I try
to add those 2 fields together.
Thanks
DS
 
DS wrote:
This works. But do I have to loop through this? Do I need the .Move
Next? etc....
Thnaks
DS

Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("SELECT * FROM Customers WHERE
Customers.CustomerID = " & Me.TxtCusID & "", dbOpenDynaset)
With rst
Do Until .EOF
Me.TxtBusinessName = !BusinessName
Me.TxtDeeName = !FName & " " & !LName
Me.TxtAddress = !Address
Me.TxtApt = !Apt
Me.TxtCity = !City
Me.TxtState = !State
Me.TxtZipCode = !ZipCode
Me.TxtTel = !Tel
Me.TxtExt = !Ext
Me.TxtFax = !Fax
Me.TxtEMail = !EMail
Me.TxtCreditLimit = !CreditLimit
Me.ChkHouseAccount = !HouseAccount
.MoveNext
Loop
End With
rst.Close
Set rst = Nothing
dbs.Close
Set dbs = Nothing
 
Duane said:
Me.TxtDeeName = !FName& " " &!LName
Thanks Duane.
Hey Duane do I need to use DAO on the recordset?
Also is this right with the loop and move next or is this unneccasary?
Thanks
DS
 
If you want to display a different record, you will need to move in the
recordset. Why don't you just use bound fields?
 
Duane said:
If you want to display a different record, you will need to move in the
recordset. Why don't you just use bound fields?
Actually I don't need a new record, its all the same record just
different fields.
Thanks
DS
 
I'm not sure what you are asking. You shouldn't need to "move next" if the
values you want to display on the form are in the current record in the
record set.
 
Duane said:
I'm not sure what you are asking. You shouldn't need to "move next" if the
values you want to display on the form are in the current record in the
record set.
Thats what I thought. So stepping back a step. Is this thing coded
properly? I tried taking out .MoveNext but then it doesn't work...so
how do I clean this thing up and take out the uneccasary coding?
Thanks
DS
 
take out the
Do Until .EOF
Use something like
If Not .EOF Then

Be sure to replace the
.MoveNext
Loop
with
End If
 
Duane said:
take out the
Do Until .EOF
Use something like
If Not .EOF Then

Be sure to replace the
.MoveNext
Loop
with
End If
Yippee! It works!
Just what I needed!
Thank You Duane.
DS
 

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

Back
Top