-
SQL Select *
Hi,
I have multiple textboxes. Let say I give my users to key in any data in textboxes then I will retrieve them from Ms Access. I have a code to check for blank[VBA]'checking for every empty textbox.
For Each tb In ActiveSheet.OLEObjects
If TypeName(tb.Object) = "TextBox" Then
If ctl = Empty Then
MsgBox ("Please enter * to retrieve all")
Exit Sub
End If
End If
Next tb[/VBA] get by some website.
my question is if user key in "*" then SQL will select unique from that column, means select all for 1 column.
[VBA]"AND (PS_DWH_ADMIN.DWH_WIP_DATA_YEAR.PROCESS_CLASS)='" & c & "' " & _
"AND (PS_DWH_ADMIN.DWH_WIP_DATA_YEAR.PRODUCT_TYPE)='" & d & "' " & _[/VBA]
I have something like this in my excel vba code where c or d = sheets.txtbox.value.
thanks
-
-
Hi SamT,
the SQL % = * put inside SQL or on the code checking for empty textbox?
-
-
By the way your first code is flawed since you use tb as the variable then check if ctl is empty. ;)
-
Hi, samT
well, I still couldn't get what you mean as it still error when I put it inside.
where is the exact location I need to put in my sql? thanks for your reply.
Aflaton: it works if I put ctl while it doesn't work if I replace it tb. I get codes from sm other place.
-
strSQL = "SELECT A,b,c " & _
strSQL = strSQL & "GROUP BY A,b,c" & _
[vba]'txtbox1 sql statement
If Worksheets("GUI").txtbox1.Value = " * " Then
strSQL2 = "SELECT Unique A " & _
"FROM D"
Else
strSQL = strSQL & "WHERE (A)='" & a & "' "
End If[/vba]
the sql statement is follow by the if statement.
Can I write like this to retrieve data from Access?
I want to retrieve the data according to user key in which I set is as variable a from txtbox value, If user key in"*" I want to select all data from that particular column.
-
Based on the code you posted ctl is an undeclared variant and would always be Empty so perhaps you have it declared elsewhere, but it still does not appear to relate to your loop which should use something like
[vba]if len(tb.object.text) = 0 then[/vba]