|
-
Oct 21st, 2011, 01:35 PM
#1
Thread Starter
Junior Member
[RESOLVED] Sql statement
Here`s my problem:
aamort = Application.InputBox("Qual o ano q pretende imprimir?", Type:=1)
strSQL1 = "SELECT ID,descricao,anoaq,valaq FROM tbltransfer where [anoaq]<=" & aamort
strSQL1 = strSQL1 & " order by ID asc"
rs1.Open "tbltransfer", cn, adOpenDynamic, adLockOptimistic, adCmdTable
I want all records with anoaq<=aamort, where aamort is a variable asked at the user.
But this statement returns all records!!
why its returning the records with anoaq>aamort
-
Oct 21st, 2011, 01:43 PM
#2
Re: Sql statement
Because you are telling it to open a table (tbltransfer) as a table. That means everything in the table comes back
Sometimes the Programmer
Sometimes the DBA
Mazz1
-
Oct 21st, 2011, 01:45 PM
#3
Re: Sql statement
You have set up strSQL1, but you aren't using it - the rs1.Open line just uses the table name.
Change it to this:
Code:
rs1.Open strSQL1, cn, adOpenDynamic, adLockOptimistic, adCmdText
-
Oct 21st, 2011, 01:51 PM
#4
Thread Starter
Junior Member
Re: Sql statement
thanks guys, its working... to
-
Oct 21st, 2011, 02:31 PM
#5
Re: Sql statement
As you now have it sorted out, could you please do us a little favour, and mark the thread as Resolved?
(this saves time reading for those of us who like to answer questions, and also helps those who search to find answers)
You can do it by clicking on "Thread tools" just above the first post in this thread, then "Mark thread resolved". (like various other features of this site, you need JavaScript enabled in your browser for this to work).
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|