Solved

VB SQL

Posted on 1998-09-02
2
221 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
Comment Utility
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
Comment Utility
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

763 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now