473,406 Members | 2,620 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,406 software developers and data experts.

MS Access Use Fld's frm Tbl1 and Data frm Tbl2

Ms Access 2010-2016 64 bit or 32 bit

The Master Table(TBL1) fields and the Imported table(Tbl2 ,3,4 ... ) fields are matched up on a form called: RefFrmCORRELATION by hand (ME) , They are kept in a table is called : RefTblCORRELATION

Table 1 Fields Master Table ( RefTblCORRELATION)
'
Tbl1.[ID],Tbl1.[RefTABLENAME],Tbl1.[Report Number],Tbl1.[SHIFT],Tbl1.[Area],Tbl1.[Beat],Tbl1.[DISTRICT],Tbl1.[GRID],Tbl1.[Occurred Date],Tbl1.[Occurred Time],Tbl1.[Reported Date],Tbl1.[Reported Time],Tbl1.[Address],Tbl1.[Incident Type],Tbl1.[UCR Description],Tbl1.[MEANSOFENTRY],Tbl1.[WEAPON],Tbl1.[ENTRYMETH],Tbl1.[ENTRYPOINT],Tbl1.[TARGETS],Tbl1.[PROPERTY],Tbl1.[SUSPECT],Tbl1.[SUSPECT2],Tbl1.[SUSPECT3],Tbl1.[SUSPECT4],Tbl1.[SUSPECT5],Tbl1.[SUSPECTVEHICLE],Tbl1.[COPPER],Tbl1.[GANGRELATED],Tbl1.[LAT],Tbl1.[LNG],

Table 2 Fields names from imported tables
'
Tbl2.[ID],Tbl2.[REPORT],Tbl2.[DATE],Tbl2.[TO_DATE],Tbl2.[DOW],Tbl2.[TIME],Tbl2.[TO_TIME],Tbl2.[SHIFT],Tbl2.[ADDRESS],Tbl2.[GRID],Tbl2.[DISTRICT],Tbl2.[AREA],Tbl2.[LOCATION],Tbl2.[WPN],Tbl2.[ENTRY_METH],Tbl2.[ENTRY_POIN],Tbl2.[TARGETS],Tbl2.[PROPERTY],Tbl2.[SUSPECT],Tbl2.[SUSPECT2],Tbl2.[SUSPECT3],Tbl2.[SUSPECT4],Tbl2.[SUSPECT5],Tbl2.[SUSP_VEH],Tbl2.[COPPER],Tbl2.[lat],Tbl2.[lng],

** the different data fields are like : tbl2.TO_Time is equal to Tbl1.{Occurred Time}

Tlb1 ' master names. I would like to use when running sql, and then displaying it in a listbox control.
'
Imported table names are like :

Tbl2 ' Imported table from different source like csv, txt, xls....
Tbl3 ' Imported table from different source like csv, txt, xls....
Tbl4 ' Imported table from different source like csv, txt, xls....

I was using the table field Names and creating individuals sql , query for each. but more tables are being added and the database is getting large due to code for the sql. I would like to automate the whole process using the field names from my main table, and the data attached to the other table.

THis way i can create the proper column(Len) for display in my listbox and show only the columns need to run and create a report and query for later use.

QUESTION
1. using vba sql is there a way to refer to the Master table : RefTblCORRELATION field name but use the data from the imported fields as seen and display in my form listbox using the Master Table Names only ?

2. if not how can I use 1 vba sql string , to create each sql statement on the fly Using Import table field names, then show my data on my main form to a listbox control
Nov 19 '18 #1
3 836
twinnyfo
3,653 Expert Mod 2GB
jc17276,

Welcome to Bytes!

First, please bear with us as we try to understand your post/question. I believe that there is an English language barrier which may make it more difficult for communication, but we will try to work through this.

Concerning your question, if I undersatnd it correctly, you ant to be able to use the Tbl1 field names in your queries of Tbl2, Tbl3, etc.?

If this is the case, you would simply provide an alias for those field names when you create the query. For example:

Expand|Select|Wrap|Line Numbers
  1. SELECT Tbl2.[TO_TIME] AS [Occurred Time], ...
provides you with a field in your query named "Occurred Time", but which holds the data of the field "TO_TIME" from Tbl2. This way the data may be interchangeable based upon Field Names.

If this is not the intent of your question, please let us know and we will try to work through it.

On a side note, I would also recommend you develop a more usable naming convention for your Db objects. "Tbl1", "Tbl2", etc. may make sense to you, but as you build your DB, at what point do you forget what "Tbl137" contains? I also recommend against field names with spaces in them, as this can make writing Queries more difficult in the lang run (even though Access allows it). If you are importing tables/spreadsheets, that can't be avoided. But in your master tables, you should avaoid it.

Hope this hepps!
Nov 19 '18 #2
twinnyfo thank you for your response. first the tables have real names not tbl1,tbl2... the table names vary from each department that send them to me. right now I have regburg,vehburg,cms201710, cms201810... I'm looking for a way to programmatically use the tables send to me, but use the field name in my TBL1 as shown (without spaces) so that I can write one vba sql, no matter which table is selected , the data field names stay the same I can then build the needed reports and queries onetime and just change the header on each report for the dataset that is used..
In my example bl2.TO_Time ( is from vehburg )table,Tbl1.{OccurredTime} is the Field name I would like to use on any table selected
Nov 19 '18 #3
twinnyfo
3,653 Expert Mod 2GB
I think I understand what you are asking for now. It seems like the import itself is as much of a project as the larger project.

I think this can be done, but it depends ont he data you are receiving. If the tables you receive are always in the same format with the same field names, you could build a table that properly references all these various tables and matches corresponding fields together.

Then, you would need to develop a SQL string builder that fully understood all the nuances of those corresponding field names, so that, when you are working on the vehburg table, the code knows to look for field TO_TIME and alias it properly as [Occured Time].

This would be quaite an involved project, but would pay dividends of automating a very slow manual process.

However, I would think you could build queries for the various tables that would alias those particular fields. You would just have several queries, and then you would have to change the Record Source of your Form. Or, you could save the query def to a common named Query that is used for the Record Source. A couple different options here. But, not seeing a more detailed picture, it's difficult to build anything remotely.
Nov 19 '18 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Patrick | last post by:
Hi all, I've installed the latest MDAC and Jet service packs on Windows 2000. On Linux I've the latest MySQL and MyODBC3.51. Using the ODBC Administrator I've set up a connection, ran the test...
2
by: gvdeynde | last post by:
Hi, What's the "best" way to have an object ObjA of class A have read-access (but not write-access) to a data member of object ObjB of class B. Class B has a std::vector<T> as a datamember. ObjA...
2
by: Craig Santoli | last post by:
"... to ASPNet as attempted from C:\WINNT\System32\WBEM\WinMgmt.exe." This error keeps appearing in the Windows 2000 Server Event Viewer. Any ideas on what's causing this or how to prevent it?...
3
by: Omar | last post by:
Hi Developers, I am trying to access an Excel data file through a VB.Net application. I have the following code: =================================== VB.Net Code =================== Dim...
2
by: David Dawson | last post by:
I have no experience using MS Access to interface with MySQL. I have a tiny MySQL database that might need to have Access connect with it over the internet and grab data/update etc. Is this...
7
by: DanZaMan | last post by:
Just a query about how clever access is, I'm using access 97. When using a "split" database with a separate front-end and with the data file on a separate server on the network how does access...
3
by: =?Utf-8?B?UGV0ZXI=?= | last post by:
I'm confused about Data Access Layer and Data Object Layer. How are they related? Which layer will be affected when the underlying database structure is changed? Which layer will be affect when...
1
by: pradnya | last post by:
Can i have more access to post data in a file other than mentioned in 'action' param ? if yes , how to achive this ? I am working with php/mapscript and using frames.. i display my...
0
by: Gabriel Genellina | last post by:
En Wed, 19 Nov 2008 20:06:37 -0200, Yann Vonder <yann.vonderscher@gmail.comescribió: If you put tmod in both libraries, you'll have two copies of it, and two copies of the data. Can't you join...
0
by: sarvmardan | last post by:
how to open a report in access containing filtered data using two combo boxes on form and a button to click. let i have two fields and other is . two comboboxes are combo11 and combo9. plz post...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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.