Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

VB SQL

Posted on 1998-09-02
2
Medium Priority
?
260 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 1

Accepted Solution

by:
wford earned 150 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

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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 Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

597 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