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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I use SQL in VBA with Combobox Value 1

Status
Not open for further replies.

rvermin

MIS
Jan 1, 2003
7
BE
Who can help with the following Problem?

I have an Access DB, that queries an AS/400 system. My Script looks like this:

Private Sub GetDataFrom As400()
Dim strSQLOld As String
Dim strSQLNew As String
Dim Dbs As DAO.Database
Dim wRSetOpenOld As Boolean
Dim wRSetOpenNew As Boolean
Dim fld As Field
Dim strName As String
Dim rstold As Recordset
Dim rstNew As DAO.Recordset
Dim Dataset As String
Dim Db As Database
Dim X As String
Dim DbName As String
Dim Datum As Integer

Dataset = "myDataset"
DbName = "System Europe"

X = "ODBC;database=" & DbName & ";DSN=" & Dataset & ""
Set Db = OpenDatabase("", False, True, X)

'Datum = 20030717
strSQLOld = "SELECT [LGFIRM], [LGWKNR], [LGTENR], [LGRGDA], FROM LPLI where ((([LGFIRM])='1') AND (([LGWKNR]='000') AND (([LGRGDA]> 20030630))))"



Set rstold = Db.OpenRecordset(strSQLOld)
wRSetOpenOld = True
'Db.Close

..... 'some more sCript follows, but is not important

End Sub


Now, My Question:

If you look at the line: "(([LGRGDA]> 20030630))))" This line queries a specific Date. 30-06-2003

How can I use three comboboxes one for year (eg. 2003) one for the month (eg. 06 one for the day (eg. 30to be used in the SQL statement for the AS/400 Query, so I can replace the 20030630.

Many thanks in advance.

Ramon



 
Try somthing along these lnes:

Dim sVar

sVar = cbo1 & cbo2 & cbo3

strSQLOld = "SELECT [LGFIRM], [LGWKNR], [LGTENR], [LGRGDA], FROM LPLI WHERE((([LGFIRM])='1') AND (([LGWKNR]='000') AND (([LGRGDA]> " & sVar & "))))"





 
ClulessChris,

Many Thanks MI(S) Friend! Appreciated your Help Very much!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top