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

Problem with Datagrid

P: 20
Hi,

My Query is "SELECT * FROM table WHERE Acc_no like '1*' "

If I run this query in Ms-Access directly, it is working fine.

but if i try to show the same result in the datagrid, it is not showing any results.

My code is :
strsql = "SELECT * FROM table WHERE Acc_no like '1*' "
Set rs = Login.conn.Execute(strsql)
Adodc1.RecordSource = strsql
Adodc1.Refresh

If I give the same like below, It is working fine.
strsql = "SELECT * FROM table WHERE Acc_no = '1' "
Set rs = Login.conn.Execute(strsql)
Adodc1.RecordSource = strsql
Adodc1.Refresh


Could you help me out in this?
Thanks in advance.

Regards,

Venkat.
Jan 29 '08 #1
Share this Question
Share on Google+
2 Replies


jamesd0142
100+
P: 469
Hi,

My Query is "SELECT * FROM table WHERE Acc_no like '1*' "

If I run this query in Ms-Access directly, it is working fine.

but if i try to show the same result in the datagrid, it is not showing any results.

My code is :
strsql = "SELECT * FROM table WHERE Acc_no like '1*' "
Set rs = Login.conn.Execute(strsql)
Adodc1.RecordSource = strsql
Adodc1.Refresh

If I give the same like below, It is working fine.
strsql = "SELECT * FROM table WHERE Acc_no = '1' "
Set rs = Login.conn.Execute(strsql)
Adodc1.RecordSource = strsql
Adodc1.Refresh


Could you help me out in this?
Thanks in advance.

Regards,

Venkat.
you have to play around with query's in vb try using:


Expand|Select|Wrap|Line Numbers
  1. strsql = "SELECT * FROM table WHERE Acc_no like " & "'" & "1%" & "'"
  2.  
its the ' thats throwing it out u see
Jan 29 '08 #2

lotus18
100+
P: 866
It is unnecessary to enclosed ' if the acc_no is a number type (access),

Rey Sean
Jan 29 '08 #3

Post your reply

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