Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA prpgramming for MA access

Status
Not open for further replies.

yacanna

Programmer
Oct 24, 2003
15
US
I have a table named "table A", include ID and Form column; so like
ID Form
1 formA
2 formB
3 formC
....

Can anybody give me a sample code for MS Access module,
basically open the table, loop through each line and print out form name. Thanks.

 
Hi!

If you're using A97 try:

[tt]dim rs as recordset
dim db as database

set db=currentdb()
set rs=db.openrecordset("Table A",dbopenforwardonly")

do while not rs.eof
debug.print rs!form
rs.movenext
loop
rs.close
set rs=nothing
set db=nothing[/tt]

If you're using access 2000+ try;

[tt]dim rs as adodb.recordset
set rs=new adodb.recordset
with rs
.activeconnection=currentproject.connection
.locktype=adlockreadonly
.cursortype=adopenforwardonly
.open "Table A", options:=adcmdtable
do while not .eof
debug.print !form
.movenext
loop
.close
end with
set rs=nothing[/tt]

NOTE - Don't use table or field names that might be confused with Access/VBA names - if the second field contains information about form names, name it FormName/FormDesc/fldForm - not "Form". It's also advicable not to use spaces in table, field, form, report.... names.

Since this is your first post, there are several Access specific forums. Do a forum search using "Access"... Also consider all forums have a faq-seqtion. Keyword search is also recommendable...:)

HTH Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top