Noob need help using VBA to create query and report

liuec

Registered User.
Local time
Today, 11:33
Joined
Jun 23, 2011
Messages
25
I would really appreciate it if anyone could help me with the below task.

I have some experience in VBA but very little with Access. The challenge I face right now is to use an index of names (in excel field) to repeatedly create reports and queries with each of these names. The reports and quires are in a set frame work so I thought this work can be completed with a loop modifying the SQL codes.

The process goes like this:
1. Create a report using person1 as the report name, modify field1 in this report.
2. Create a drop_query_person1 that drops table_person1 using person1's name.
3. Create a make_query_person1 that makes table_person1 using person1's name.
4. Execute make_query_person1 to make table_person1
5. Create append_query_person1 that would fill table_person1 from some other data source.
6. Execute append_query_person1 to fill table_person1 from an existing table called table_source.
7. Create query_person1 that sorts table_person1
8. And repeat the above steps using person2's name and on until the end of index.

Is it possible to use VBA to edit report?
What goes on the header in the VBA codes? (revise) what things do I need to declare in the header of the codes? Honestly I've forgotten a lot of things in VBA already..

If I want to dim a string that stores person1....100's name, how would I put it in the contest in terms of SQL code? For instance if I dim prs as a string, how would I use this variable, prs, to replace JohnDoe in the code below? (how does quotation work here?)

INSERT INTO [TBL_JohnDoe] ( JohnDoe_field, Personal_Info, Gender, Age)

Some sample code would really be helpful.
I know this sounds very noobie, but I'd really appreciate any inputs/help here.

Thanks a lot!!
 
Last edited:
1. Yes, you can modify reports with VBA the same way you can modify forms.

2. Not Sure I understand what youre asking. Ill just leave this for now.

3. Since SQL source must be input as a string in VBA:

"INSERT INTO [TBL_" & prs & "] ( JohnDoe_field, Personal_Info, Gender, Age)"
 
1. Yes, you can modify reports with VBA the same way you can modify forms.

2. Not Sure I understand what youre asking. Ill just leave this for now.

3. Since SQL source must be input as a string in VBA:

"INSERT INTO [TBL_" & prs & "] ( JohnDoe_field, Personal_Info, Gender, Age)"

Thanks for the quick response, for the "INSERT INTO...." code would I do the same for "JohnDoe_field" part as well? ie. is " & prs & "_field the correct way to replace JohnDoe here?
 

Users who are viewing this thread

Back
Top Bottom