|
-
Mar 27th, 2000, 08:04 PM
#1
Thread Starter
Lively Member
Hello I will be so thankful for help on this: I am trying to use one form that will change according to who accesses it. I am using an ADO and a datagrid on the form. So I am trying to change the recordset for the ADO at runtime. Everything I have found says to use the following code but it will not REFRESH. Any help or suggestions on how you changed your ADO recordset at runtime. Thanks Much.
Private Sub Form_Load()
Dim strquery As String
With frmSkipGAFL.Adodc3
.Mode = adModeReadWrite
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.3.51;Persist Security Info=False;Data Source=S:\DBAPPS\Repo\RepoInv.mdb"
.CommandType = adcommandtext
End With
strquery = "SELECT * FROM RepoInventory WHERE RepoStatusID = 12"
Adodc3.RecordSource = strquery
Adodc3.Refresh
End Sub
-
Mar 27th, 2000, 08:23 PM
#2
Thread Starter
Lively Member
Actually it is telling me that there is a data type mismatch in the criteria expression. Help
-
Mar 27th, 2000, 08:44 PM
#3
Lively Member
Refresh
I have an upcoming enhancement I will be making to one of my programs which will perform a similar function. I know that on the mainframe you can't change the query on the fly like that (Where clause). You have to close and open again with the new query. I was starting to wonder if I would have to do that in VB too. Perhaps you have to do something similar to get it to work. Let me know what you come up with!
-
Mar 27th, 2000, 10:04 PM
#4
Thread Starter
Lively Member
I found the problem was in my syntax, the sql statement needed to be:
"SELECT * FROM RepoInventory WHERE repoinventory.RepoStatusID = " & "'" & 11 & "'"
and it works beautifully!
-
Mar 27th, 2000, 11:39 PM
#5
If you use a hard coded value, then you don't have to concatenate your SQL statement. You can do it like this:
strquery = "SELECT * FROM RepoInventory WHERE RepoStatusID = '12'"
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
|