Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Asking the user for a table name 1

Status
Not open for further replies.

supervi

MIS
Mar 22, 2003
61
0
0
CA
I have a subform that has this has the record source

SELECT DISTINCTROW [extract].[ID], [extract].[Req #], [extract].[Rec Typ], [extract].[Rev Cd],Crtn Dt], [extract].[Crtn User] FROM [extract];

Obviously its from the table extract. When this form opens, i want it to ask the user "what is the name of the table that you have imported?" Instead of it always defaulting to extract.

What would be the easiest way to do this?
 
Paste the following code into your form's code module:
Code:
[COLOR=blue]Private Sub[/color] Form_Open(Cancel [COLOR=blue]As Integer[/color])

    [COLOR=blue]Dim[/color] tblName [COLOR=blue]As String[/color]
    tblName = InputBox("what is the name of the table that you have imported?")
    Me.RecordSource = "SELECT DISTINCTROW [ID], [Req #], [Rec Typ], [Rev Cd], [Crtn Dt], [Crtn User] FROM [" & tblName & "];"

[COLOR=blue]End Sub[/color]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top