?
Solved

VB SQL

Posted on 1998-09-02
2
Medium Priority
?
255 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
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…
Suggested Courses
Course of the Month14 days, 5 hours left to enroll

801 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