Vb6,MS ACCESS 2003, AD0 2.8

How Do i replace TableName with variable in sql select statement?

Page 1 of 1

2 Replies - 1856 Views - Last Post: 04 April 2010 - 05:41 PM Rate Topic: -----

#1 Guest_evry1falls*


Reputation:

Vb6,MS ACCESS 2003, AD0 2.8

Posted 30 March 2010 - 08:38 PM

Im trying to work with a table in the database , and the problem is that i will change the table name while im working ..... meaning:

i have a database access 2003 (Ahmed.mdb), tale name (atf105)

so i connected the database and the table using Ado 2.8

and .....
If RS.State = 1 Then RS.Close
RS.CursorLocation = adUseClient
RS.Open "select * from [b]atf105 [/b]where InvCurr = '" & Invoices.CboCntCur.Text & "'", CN, adOpenDynamic, adLockOptimistic


I WANT TO REPLACE THE (atf105) with a variable like (x) ... because i will open anytable according to something else .. and (atf105) is just one of the tables in the database .

how can i do this >>>>

Is This A Good Question/Topic? 0

Replies To: Vb6,MS ACCESS 2003, AD0 2.8

#2 vb5prgrmr  Icon User is offline

  • D.I.C Lover

Reputation: 109
  • View blog
  • Posts: 1,016
  • Joined: 21-March 09

Re: Vb6,MS ACCESS 2003, AD0 2.8

Posted 30 March 2010 - 09:40 PM

Dim TableName As String, strSQL As String
TableName = "The table name"
strSQL = "SELECT * FROM " & TableName & " WHERE somefield = " & somevalue





Good Luck
Was This Post Helpful? 0
  • +
  • -

#3 Guest_evry1falls*


Reputation:

Re: Vb6,MS ACCESS 2003, AD0 2.8

Posted 04 April 2010 - 05:41 PM

Thanx Man, you have been a big help
Was This Post Helpful? 0

Page 1 of 1