SunQuest
           MS SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMS SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today!
  #1  
Old February 27th, 2004, 06:33 PM
BratCat2 BratCat2 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 20 BratCat2 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Similar Wildcard problem

I have a similar wildcard problem that's on a earlier thread except I am trying to do a CreateParmsQuery so that when a user adds a new record to the database, a query is created using the name they type into the Textbox field which is bound to the database.

I already have the function CreateParmsQuery but I think my syntax is wrong.

This is the function:
Sub CreateParamsQuery(strDBPath As String, _
strSQL As String, _
strQryName As String)
Dim catDB As ADOX.Catalog
Dim cmd As ADODB.Command
Set catDB = New ADOX.Catalog
' Open the Catalog object.
catDB.ActiveConnection "Provider=Microsoft.Jet.OLEDB.4.0;"&_ "Data Source=" & strDBPath

'Create a Command object to contain the query's definition.
Set cmd = New ADODB.Command

cmd.CommandText = strSQL

'Add the query to the Procedures collection.
catDB.Procedures.Append strQryName, cmd

Set catDB = Nothing
End Sub

Here is my Query

CreateParamsQuery "C:\Downloads\PSBDir10142002\database\db6.mdb", "Select Participants.Event, Participant.Full_Name,Participants From Participants WHERE (Participants.event = ''events1.text1.text'')"

Events1 is the form
Text1 is bound to the event field and is where the user types in the name of the event.

THX

Reply With Quote
  #2  
Old March 1st, 2004, 11:35 AM
sypher sypher is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: Montreal
Posts: 92 sypher User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 m 10 sec
Reputation Power: 5
[/QUOTE]WHERE (Participants.event = ''events1.text1.text'')"[QUOTE]

should be
WHERE (Participants.event = ''+events1.text1.text+'')"

the rest seems fine but check this line
(if it doesn't work try to heardcode the Participants.event for a test)

Reply With Quote
  #3  
Old March 1st, 2004, 03:51 PM
BratCat2 BratCat2 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 20 BratCat2 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Works - kind of

It creates the query correctly but when I open it in Access of course it asks for the parameter since the query doesn't know what text1.text is.

That's OK. I really want it to run the query in the VB form.
Can I use a similar fuction to run the query from the form ?
Use this:
Set cmd = New ADODB.Command
cmd.CommandText = ???

instead of what is there now ?

THX for all your help with this.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMS SQL Development > Similar Wildcard problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway