Solved

VB SQL

Posted on 1998-09-02
2
242 Views
Last Modified: 2010-04-30
I am familiar with SQL in Visual Foxpro. Obviously SQL in VB is a little different!   Where do I put a SQL statement (other than the recordsource property of a data control)that will return results to a flex grid? (I would rather not use debug.print to show the results). I would also like to allow the user, I guess through seek, to determine the search variable.

Thanks!
0
Comment
Question by:foxsage
2 Comments
 
LVL 1

Accepted Solution

by:
wford earned 50 total points
ID: 1432529
You can set the sql statment thru the openrecordset method and assign to a recordset, then assign this recordset to the flexigrids bound data control and there you go...

Dim Sqlstr As String, userInput As String
Dim yourRS As Recordset
Dim yourDB As Database
Dim ws As Workspace

Set ws = Workspaces(0)
Set yourDB = ws.OpenDatabase(Data1.DatabaseName)
 
userInput = "VW"

Sqlstr = "SELECT * FROM yourtable Where YourCriteria = '" & Trim$(userImput) & "*'"
Set yourRS = yourDB.OpenRecordset(Sqlstr, dbOpenDynaset)

'now set your data control to this rs then voila!

Set Data1.Recordset = yourRS
0
 

Expert Comment

by:coggie
ID: 1432530
Hi there,

Is this any help:-

Set qry = CurrentDB.CreateQueryDef("", "Select * from <TableName>")

rather than use seek use find first after the previous line like this:-

Set rst = qry.OpenRecordset()
With rst
 .FindFirst ("UserName = '" & sUserNameEntered & "' AND UserPWD = '" & sPasswordEntered & "'")

hope this helps

Regards,

Coggie
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question