Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 16th, 2007, 08:34 PM
Registered User
 
Join Date: Jan 2007
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Setting Text Fields in a Tabular Form

I have an Access tabular form whose detail section contains several text box controls, Text1, Text2, Text3 etc. I want to iterate through a programmatically created recordset rsMyForm, assigning values from the recordset to the text box controls on the form, for example:

Me.Text2 = rsMyForm!Some_Column

Can anyone tell me how to do this?

I'm an experienced VBA programmer and have build some pretty sophisticated forms, but my experience with tabular forms is limited to forms that run off a table or query.

Thanks much!

AppBuilder
Reply With Quote
  #2 (permalink)  
Old January 17th, 2007, 08:19 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

I think you would use the On Current event of the main form. The tabbed form is part of the main form, unless you put a subform on it. If there are just text boxes, then they would work off the main form events.

So for the main form's On Current event:

Declare variables

Set and create recordset, and I am assuming one record in the recordset.

Then:

rsMyForm.Open sSQL, CurrentProject.Connection, etc

Me.Text1 = rsMyForm("Some_Column1")
Me.Text2 = rsMyForm("Some_Column2")
Me.Text3 = rsMyForm("Some_Column3")
Me.Text4 = rsMyForm("Some_Column4")

rsMyForm.Close

Then if you have update events, you need to code those as well.

Perhaps a queryand subform would work as well.

HTH



mmcdonal
Reply With Quote
  #3 (permalink)  
Old January 17th, 2007, 01:57 PM
Registered User
 
Join Date: Jan 2007
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you for responding, mmcdonal.

Unfortunately

o This is a stand alone form, with one line in the form for each record in the recordset, and some counts and totals in the footer.

o I want to iterate through the recordset putting information extracted and calculated from one record into each line.

o Because of the way I'm selecting and computing information from the recordset, I can't just bind the fields in the record to controls. I need to look at the data and then decide which text control to put it into.

AppBuilder
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA code to Search All Text Fields on a form dezmond2 BOOK: Access 2007 VBA Programmer's Reference ISBN: 978-0-470-04703-3 1 July 7th, 2007 11:58 AM
copy fields from Form to new form - openargs justabeginner Access VBA 1 February 4th, 2007 01:28 PM
setting date/time fields back to null value badgolfer Access 1 August 8th, 2005 02:29 AM
Setting Focus on a Text Box in a Web Form vbmazza VB.NET 1 May 4th, 2005 09:19 AM



All times are GMT -4. The time now is 06:57 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.