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

Dynamically query a table to OpenForm with an Access Database!!!

I have to work with an existing database with 25 tables.
I want the end User to be able to modify rows within the tables (add/amend/delete) via a Form. I do not want to create a query for the form, I want to dynamically create a query to access the table to then display the table within an editable form. Can this work? Anybody got any ideas of how I could do this?

I have tried the following syntax using VBA (access2000), but this does not work. I get no response! I am also confused with the building of my SQL string??? I am going mad here...
Any h elp will be much appreciated!

Thank you All!


~~~~~~~~~~~~~~~~~~~~~~
Dim strFormName As String
Dim strQueryName As String
Dim strSQL As String
Dim stLinkCriteria As String

strFormName = "FrmDelivery"

DoCmd.OpenForm strFormName, acNormal, , "SELECT * FROM " & cboAcctName " & "WHERE (((" & cboAcctName & ".Location)=""));", acFormEdit, acWindowNormal

~~~~~~~~~~~~~~~~~~~~~~
Nov 3 '06 #1
6 2151
NeoPa
32,556 Expert Mod 16PB
expression.OpenForm(FormName, View, FilterName, WhereCondition, DataMode, WindowMode, OpenArgs)
You will see that a full SELECT query is not expected here.
You can enter a WHERE condition here, but the forms Record Source cannot be set at this point.
To set that to your own SQL, add it in the OnOpen event of the form.
Nov 3 '06 #2
PEB
1,418 Expert 1GB
And in the same form you want to display all 25 tables with the respectiv criterias...

So you need few things..

In your form have enough fields = max of fields of your tables... To be sure that it's ok create 255 fields...

Than when you want to visualise a table you need to access the tableDefs section and retrieve the information about the fields

Set all fields from the table to your fields in the form... /This is the control Source property

At the end generate your SQL as a filter... and your table in recordset property..

Your code seems very small to perform all this things... Consult TableDef property for more info..

:)

I have to work with an existing database with 25 tables.
I want the end User to be able to modify rows within the tables (add/amend/delete) via a Form. I do not want to create a query for the form, I want to dynamically create a query to access the table to then display the table within an editable form. Can this work? Anybody got any ideas of how I could do this?

I have tried the following syntax using VBA (access2000), but this does not work. I get no response! I am also confused with the building of my SQL string??? I am going mad here...
Any h elp will be much appreciated!

Thank you All!


~~~~~~~~~~~~~~~~~~~~~~
Dim strFormName As String
Dim strQueryName As String
Dim strSQL As String
Dim stLinkCriteria As String

strFormName = "FrmDelivery"

DoCmd.OpenForm strFormName, acNormal, , "SELECT * FROM " & cboAcctName " & "WHERE (((" & cboAcctName & ".Location)=""));", acFormEdit, acWindowNormal

~~~~~~~~~~~~~~~~~~~~~~
Nov 4 '06 #3
Hello PEB,
What happens is that a User will select ONE Table to be displayed from a combo box drop down list.
I would then like the table to open up into a form (displaying all 8 column fields and all the rows of data from the tables).
I require form, so that the User can then make updates to this table!

Hope my query makes more sense!
I am sure that there is a simple solution, but I can figure one out!

I would like this application to work dynamically, rather than having to create 25 queries!

Mel

~~~~~~~~~~~~~~~~~~~~~
And in the same form you want to display all 25 tables with the respectiv criterias...

So you need few things..

In your form have enough fields = max of fields of your tables... To be sure that it's ok create 255 fields...

Than when you want to visualise a table you need to access the tableDefs section and retrieve the information about the fields

Set all fields from the table to your fields in the form... /This is the control Source property

At the end generate your SQL as a filter... and your table in recordset property..

Your code seems very small to perform all this things... Consult TableDef property for more info..

:)
Nov 5 '06 #4
VALIS
21
Hello PEB,
What happens is that a User will select ONE Table to be displayed from a combo box drop down list.
I would then like the table to open up into a form (displaying all 8 column fields and all the rows of data from the tables).
I require form, so that the User can then make updates to this table!

Hope my query makes more sense!
I am sure that there is a simple solution, but I can figure one out!

I would like this application to work dynamically, rather than having to create 25 queries!

Mel

~~~~~~~~~~~~~~~~~~~~~
Mel,

Are the 8 fields common to all the tables?
If not, are there always 8 fields in a table?

If so you could have a generic form with 8 fields.
Your code could change the controlsource property of the form depending on the selection.
If the field names are different for each table you will need to right some code looping through the controls collection to change the control source of each control.
Nov 6 '06 #5
Well my MAIN PROBLEM is how can I display a FORM dynamically?
I do not want to creat 25 queries. When a user selects a table to be displayed as a form, how can I pass through an SQL query (of sone sor) so that the correct information is shown in the FORM that has already been created?



~~~~~~~~~~~
Mel,

Are the 8 fields common to all the tables?
If not, are there always 8 fields in a table?

If so you could have a generic form with 8 fields.
Your code could change the controlsource property of the form depending on the selection.
If the field names are different for each table you will need to right some code looping through the controls collection to change the control source of each control.
Nov 6 '06 #6
VALIS
21
Well my MAIN PROBLEM is how can I display a FORM dynamically?
I do not want to creat 25 queries. When a user selects a table to be displayed as a form, how can I pass through an SQL query (of sone sor) so that the correct information is shown in the FORM that has already been created?



~~~~~~~~~~~
You won't need to write any queries.
If all the tables have 8 fields all you need to do is change the record source of the controls to reflect the fields of the table selected.

Dim ctl as control


For Each ctl in Myfrm.Controls
Nov 6 '06 #7

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

Similar topics

4
by: George Stout | last post by:
First off I do not know alot about writing queries to an Access Database from an ASP page. This is why I need help. I have an Events database for 6 colleges in our metro area. On the homepage I...
41
by: Ruby Tuesday | last post by:
Hi, I was wondering if expert can give me some lite to convert my word table into access database. Note: within each cell of my word table(s), some has multi-line data in it. In addition, there...
3
by: Eric Carr | last post by:
I have been trying to create a table in an Access database via a VB.NET program and I am running into a problem defining an autoincrement field. I am getting an error saying "Property 'Item' is...
3
by: eagleofjade | last post by:
I am trying to help a friend who is learning VB.net in school. I have done VB programming for a number of years using VB 6. He needs to open a query in an Access database that has parameters so he...
5
by: Sorin Marin | last post by:
Hi Experts, I have some Oracle views linked in an Access database ¬ this is the good part. Now I try to link to an Access query from other database (still Access) but I have no clue how. I'm a bit...
2
by: deep2389 | last post by:
Hi, I have a sample ASP code which should get the records from a table in ACCESS database. However, while running the page I am getting the following error: "Microsoft OLE DB Provider for...
2
by: occyink | last post by:
I run a website selling cartridges. My stock on the website is in a MySql database. My accounts package and invoicing software runs on an Access database. In my website databse there is a table...
0
by: jdirienzi | last post by:
I am in the unfortunate position of attempting to work with an Access database on a network share. My client has two separate access databases - one that contains all of the company's data and one...
0
by: apcalogic | last post by:
I have a Bluetooth enabled Laptop & I have 2 Bluetooth enabled mobiles named as AX1 & AY1 My Laptop display these mobiles in main window of Bluetooth as follows AX1 AY1 I am aware that...
1
by: eric bilal | last post by:
i have a table tablessales on a database1.mdb. now i want to export the said table to newdatabase.mdb how to code this pls thank you
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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
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.