473,407 Members | 2,315 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Automate run all table names in Combo box

I have a form with a combo box and button that creates tables based on a group of records by a variable name of a value in a field. The combo box holds the values and the button executes the code below. This all works fine, however I need a button for when the list is long in the combo box to run all instances of possible tables (I still need the single run feature).

This is where it all goes south. I have tried a For Each statemtent but I usually don't ever get that far with VB in MS Access. Here is a sample of the code that works and an unfinished sample of something I came up with to try a run all button. I appreciate andy help.

Working-

Private Sub Command2_Click()
Dim strSQL As String
Dim strSourceSelected As String
strSourceSelected = Trim$(Me![Combo5])

strSQL = "SELECT Split.* INTO " & strSourceSelected
strSQL = strSQL & " FROM Split"
strSQL = strSQL & " WHERE Split.Field4 = [Forms]![Create_Split]![Combo5]"
DoCmd.RunSQL strSQL
End Sub
Not Working-

Private Sub Command2_Click()
Dim strSQL As String
Dim strSourceSelected As String
Dim strSourceSelected2 As Variant
Dim strSourceSelected3 As Variant
strSourceSelected = Trim$(Me![Combo5])
strSourceSelected2 = Trim$(Me![Combo5])
strSourceSelected3 = "Select Field4 From Market_Distinct"

For Each strSourceSelected2 In strSourceSelected3
strSQL = "SELECT Market.* INTO " & strSourceSelected
strSQL = strSQL & " FROM Market"
strSQL = strSQL & " WHERE Market.Field4 = strSourceSelected"
DoCmd.RunSQL strSQL

Next
End Sub

--
Message posted via http://www.accessmonster.com
Nov 13 '05 #1
4 1420
Before you go any further down this road, perhaps we could have an
explanation of why you're wanting this rather unorthodox procedure.
If you read through the posts in this and similar forums, you'll find many,
many instances where people are advised to put tables with similar
structures together into a single one. The reasons for this are multiple
and compelling.
But here you are wanting to do the opposite.
Why?

- Turtle

"Chris via AccessMonster.com" <fo***@AccessMonster.com> wrote in message
news:a9******************************@AccessMonste r.com...
I have a form with a combo box and button that creates tables based on a group of records by a variable name of a value in a field. The combo box
holds the values and the button executes the code below. This all works
fine, however I need a button for when the list is long in the combo box to
run all instances of possible tables (I still need the single run feature).
This is where it all goes south. I have tried a For Each statemtent but I usually don't ever get that far with VB in MS Access. Here is a sample of
the code that works and an unfinished sample of something I came up with to
try a run all button. I appreciate andy help.
Working-

Private Sub Command2_Click()
Dim strSQL As String
Dim strSourceSelected As String
strSourceSelected = Trim$(Me![Combo5])

strSQL = "SELECT Split.* INTO " & strSourceSelected
strSQL = strSQL & " FROM Split"
strSQL = strSQL & " WHERE Split.Field4 = [Forms]![Create_Split]![Combo5]"
DoCmd.RunSQL strSQL
End Sub
Not Working-

Private Sub Command2_Click()
Dim strSQL As String
Dim strSourceSelected As String
Dim strSourceSelected2 As Variant
Dim strSourceSelected3 As Variant
strSourceSelected = Trim$(Me![Combo5])
strSourceSelected2 = Trim$(Me![Combo5])
strSourceSelected3 = "Select Field4 From Market_Distinct"

For Each strSourceSelected2 In strSourceSelected3
strSQL = "SELECT Market.* INTO " & strSourceSelected
strSQL = strSQL & " FROM Market"
strSQL = strSQL & " WHERE Market.Field4 = strSourceSelected"
DoCmd.RunSQL strSQL

Next
End Sub

--
Message posted via http://www.accessmonster.com

Nov 13 '05 #2
I need multiple tables because a script run from another department via
cold fusion is accessing those tables based on information accessed via
web. Also each segment of records contatins complicated integration with
other files as well.

So to make a complicated story short I am trying to retrofit into an
existing process, as I think this would be easier than rewriting the whole
process. (that would be beyond my control anyway).

Thanks

--
Message posted via http://www.accessmonster.com
Nov 13 '05 #3
I am still in limbo on this? Is there anyone who could provide assistance?

--
Message posted via http://www.accessmonster.com
Nov 13 '05 #4
Well, I still don't like this approach (think in the long run you'd be
better off doing the rewrite), but here's one approach to what you're trying
to do:

First, here's my understanding of what you need:
Instead of selecting one value of Field4 in your table Market, you want
to create a separate table for each value in Field4, all at once.
So there's nothing to choose from the combobox; it goes away, or is at
least irrelevant.
You have a query Marketing_Distinct which gives you the distinct values
in Field4.
(WARNING: AIR CODE)

Private Sub Command2_Click()
Dim strSQL As String
Dim strSourceSelected As String
Dim RS as DAO.RecordSet
Set RS=CurrentDB.OpenRecordset( "Select Field4 From Market_Distinct")

Do Until RS.EOF
strSourceSelected=RS!Field4
strSQL = "SELECT Market.* INTO " & strSourceSelected
strSQL = strSQL & " FROM Market"
strSQL = strSQL & " WHERE Market.Field4 = strSourceSelected"
DoCmd.RunSQL strSQL
RS.MoveNext
Loop

RS.Close
Set RS=Nothing

End Sub

"Chris via AccessMonster.com" <fo***@AccessMonster.com> wrote in message
news:08******************************@AccessMonste r.com...
I am still in limbo on this? Is there anyone who could provide assistance?

--
Message posted via http://www.accessmonster.com

Nov 13 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Tony Williams | last post by:
I have two tables one lists the names of committees and the other is a list of documents they generate. I have a form based on the documents table which gives details of the document including...
1
by: rob | last post by:
I built a combo box that contains names of people. A user can chooses a person from the combo box, the next couple of the text boxes will show the corresponding address of that person. I used...
1
by: Chris Arenburg via AccessMonster.com | last post by:
I have a form with a drop down selection. The dropdown contains a list of table names and next to it a button. So the operator would go through and select a table and hit the create table button. And...
1
by: JohnM | last post by:
Hi, I want to use a combo box to select from tables in a database. (Specifically, tables with a certain string in the name ... e.g MarkBk7l, Markbk8R etc.) How do I get a list of table into a...
9
by: Ots | last post by:
I'm using SQL 2000, which is integrated with a VB.NET 2003 app. I have an Audit trigger that logs changes to tables. I want to apply this trigger to many different tables. It's the same trigger,...
11
by: Gilberto | last post by:
Hello I have a table PRODUCT NAMES with fields PRODUCTNAME and COMMODITY, another table called COMMODITY NAMES with the only field COMMODITIES (containing a list of 7 different commodities), and a...
2
by: banderson | last post by:
Hello, I have a data entry form for a table with information about buildings and am having a problem making a combo box do what I want. I would like to make the combo box show a list of unique bldg...
14
by: Mark | last post by:
I have a table with a field that uses a combobox to populate values. The Lookup tab within table design mode is the following: Display Control Combo Box Row Source Type ...
4
by: Neil | last post by:
Having trouble with inserting a record into a table. It's a list of names. But, for some reason, it won't take a particular name. When a user tries to enter a name into the table, the system hangs...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.