By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,162 Members | 996 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,162 IT Pros & Developers. It's quick & easy.

Forms Running Queries

P: 7
i have a form which will display district_names in combo box(cmbdist), when i select this it will display name_school in combo box(cmbschool), when i select this it will run a query how? i used to do like this but error occuring syntax error in FROM clause.

select sno,name_teacher,division from " & me.cmbdist.text & " where name_school = "[forms]![Form6]![cmbschool].column(0)"; in Query3

and i tried this one also

select sno,name_teacher,division from "[forms][Form6][cmbdist].text" where name_school = "[forms]![Form6]![cmbschool].column(0)"; in Query3

i didnt get

this is my combo box(cmbschool) vba code

Private Sub CMBSCHOOL_Change()
Dim stDocName As String
stDocName = "Query3"
DoCmd.OpenQuery stDocName, acViewPreview, acEdit
End Sub

actually in district table district_names field have(bokaro,dumka,chaibasa) data
these are again tables-for bokaro,dumka,chaibasa data is same as (sno,name_teacher,division). tell me urgent
Dec 12 '06 #1
Share this Question
Share on Google+
5 Replies

Expert Mod 15k+
P: 31,660
What you've posted for the queries seems to start in the middle of a line. The first quotes are missing and it doesn't show what you do with the resultant string.
Can you repost with code tags and the whole lines please.
Without that this just doesn't make sense.
Dec 12 '06 #2

Expert Mod 10K+
P: 14,534
It's not clear if cmbdist hold the names of your tables or if you have one table called district. If it's the latter then you will need to do the following

Expand|Select|Wrap|Line Numbers
  1. SELECT sno,name_teacher,division 
  2. FROM district  
  3. WHERE name_school = "[forms]![Form6]![cmbschool].column(0)
  4. AND district_name='" & me.cmbdist.text & "'";
Dec 13 '06 #3

P: 7
In queries(Query3)
select sno,name_teacher,division from " & me.cmbdist.text & " where name_school = "[forms]![Form6]![cmbschool].column(0)";

dim strsql as string
docmd.OpenQuery "Query3",acViewNormal,, acEdit

it didnt open query. i tried another one like this but wont create a

Dim STRSQL, STR As String
Dim STR1 As String
Set DBS = CurrentDb
STR = cmbdist.Text
STR1 = cmbschool.Text
Debug.Print "SQL Statement: " & STRSQL
Set DBS = CurrentDb
Set GDF = DBS.CreateQueryDef(QUERY3, STRSQL)
Dec 13 '06 #4

Expert Mod 10K+
P: 14,534
You haven't answered the question about what is your table name?
Dec 13 '06 #5

Expert Mod 15k+
P: 31,660
And I can't help either as you've ignored my post completely (Post #2).
Dec 14 '06 #6

Post your reply

Sign in to post your reply or Sign up for a free account.