Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Display table via a click on a button...

Posted on 2003-12-08
11
Medium Priority
?
342 Views
Last Modified: 2006-11-17
Without letting admin/user go to database window, I want table to be selected from a list box and viewed via a click on PreviewTable button (list box and button are done).

As you know RunSQL wouldn't work for Select queries.  Do you know how to display a table directly from a form?

Dim sqlStr As String                     \
sqlStr = "Select * From site"         |   this wouldn't work
DoCmd.RunSQL sqlStr                  /

Teach me how it is done.

Thanks,

Mike
0
Comment
Question by:Mike Eghtebas
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 3
11 Comments
 
LVL 4

Expert Comment

by:dasari
ID: 9902362
Well, U can use ADO to do that......
0
 
LVL 34

Author Comment

by:Mike Eghtebas
ID: 9902366
Code is what I need.
0
 
LVL 4

Expert Comment

by:dasari
ID: 9902369
Where do u want to view the data of the table....., I mean some kinda report or user defined form?

0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
LVL 10

Accepted Solution

by:
jobrienct earned 2000 total points
ID: 9902386
hi Mike :)

Do you mean open the table in Normal view?

DoCmd.OpenTable "Employees", acViewNormal, acEdit


from the help...

  acViewDesign
acViewNormal (default)
acViewPreview

  acViewNormal opens the table in Datasheet view.
  If you leave this argument blank, the default constant
(acViewNormal) is assumed.

datamode One of the following intrinsic constants:
  acAdd
acEdit (default)
acReadOnly
  If you leave this argument blank, the default constant (acEdit) is assumed.


regards,

John
0
 
LVL 4

Expert Comment

by:dasari
ID: 9902387
Dim adoCN As New ADODB.Connection
Dim adoRS As New ADODB.Recordset
Dim strTableName as String
Dim strSQL as String

adoCN.ConnectionString = CurrentProject.Connection
adoCN.Open

strSQL = "SELECT * FROM " & strTableName

adoRS.Open strSQL, adoCN, adOpenDynamic, adLockOptimistic

Do While adoRS.EOF = False
    Debug.Print adoRS(0)  'Prints the first Field value
    Debug.Print adoRS(1)  'Prints the second Field value
    'etc etc
    adoRS.MoveNext
Loop

Set adoRS = Nothing
Set adoCN = Nothing

'Don't forget to set a reference to "Microsoft ActiveX Data Objects 2.7 Library" or which ever version is the latest  on your PC.......
'Assuming strTableName holds the table name selected from the list box
0
 
LVL 10

Expert Comment

by:jobrienct
ID: 9902392
oh, I just noitced you said preview mode,

DoCmd.OpenTable "TblName", acViewPreview

John
0
 
LVL 4

Expert Comment

by:dasari
ID: 9902426
sorry for the doubling's; refreshed the window again........
0
 
LVL 4

Expert Comment

by:dasari
ID: 9902439
Well, I thought I pasted my comment twice....never mind.....

The Row Source Property of the list box will contain the following query to show list of user tables available in the current database......

SELECT MSysObjects.Id, MSysObjects.Name FROM MSysObjects WHERE Type=1 And Flags=0 ORDER BY Name;
0
 
LVL 34

Author Comment

by:Mike Eghtebas
ID: 9902505
Thank you John,

My overworked mind couldn't figure that.  I appreciate the time.
---------
Hi dasari,

I will post your points shortly.

Regards,

Mike
0
 
LVL 34

Author Comment

by:Mike Eghtebas
ID: 9902533
0
 
LVL 10

Expert Comment

by:jobrienct
ID: 9902570
My pleasure Mike, glad I could help kickstart you.. now for a bit of sleep :-)

considering how simple that was it barely seems reasonable to take 500pts for it, but I don't have any change on me! :-o

Gnite,

John
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question