Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

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 ASP Free Forums Sponsor:
  #1  
Old October 20th, 2004, 04:20 PM
jasondatabase jasondatabase is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 4 jasondatabase User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question Append Query

Hello,
Another question about VB for Access. Does anyone know how to create a user input for a filter which is used in more than one append query?.
Here is what I have so far:

Private Sub Command32_Click()
DoCmd.SetWarnings False
DoCmd.OpenQuery "DELETEQUERY", acViewNormal, acEdit
DoCmd.OpenQuery "APPEND1", acViewNormal, acEdit
DoCmd.OpenQuery "APPEND2", acViewNormal, acEdit
DoCmd.OpenQuery "APPEND3", acViewNormal, acEdit
DoCmd.OpenQuery "APPEND4", acViewNormal, acEdit
DoCmd.OpenQuery "APPEND5", acViewNormal, acEdit
DoCmd.SetWarnings True
End Sub

Three of my append queries have a filter that prompts the user for a "Job Number". The same "Job Number" is used for all three append queries. The problem is that it prompts the user three times for the same number.
My question is... Does anyone know how to prompt the user one time for a "Job Number", which then uses that input for the filters for append query 2,3,4?
Thank you,
Jason
PS - Thanks JamesLee for your expertise regarding the SetWarnings!!!!!

Reply With Quote
  #2  
Old October 20th, 2004, 04:53 PM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 21 h 32 m 23 sec
Reputation Power: 180
I'd use code myself, like this (only an example):

Code:
  Dim Con as adodb.connection
  Set con = CurrentProject.Connection  'This may not be exactly right
  Dim sql as string
  sql = "INSERT table (col1, col2) VALUES ('val1', " & jobid & ")"
  con.execute sql

You can open the sql view in the query window and for the most part copy & paste the sql into your code.

Otherwise I don't know, I suppose some kind of parameter query.
__________________
======
Doug G
======
I didn't attend the funeral, but I sent a nice letter saying I approved of it. --Mark Twain

Reply With Quote
  #3  
Old October 20th, 2004, 06:03 PM
JamesLe JamesLe is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: Oakland, CA, USA
Posts: 131 JamesLe User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 6 m
Reputation Power: 4
RE: Append Query

Hello jasondatabase,

Doug G is right. Instead of creating your queries in design view it's more flexible with SQL statement. Hope it will help you start.

'------------------------------------
Private Sub Command32_Click()
Dim MyDB As Database, MySet As Recordset, Res As Variant
Set MyDB = CurrentDb
DoCmd.SetWarnings False
DoCmd.OpenQuery "DELETEQUERY", acViewNormal, acEdit

Res = InputBox("Enter Job Number: ", "Get Job Number")
DoCmd.RunSQL ("INSERT INTO table1 SELECT * FROM table2 WHERE jobID = '" & Res & "';")
DoCmd.RunSQL ("INSERT INTO table3 SELECT * FROM table4 WHERE jobID = '" & Res & "';")
DoCmd.RunSQL ("INSERT INTO table5 SELECT * FROM table6 WHERE jobID = '" & Res & "';")

'Want to do something with recordset
Set MySet = MyDB.OpenRecordset("SELECT...;")
Do Until MySet.EOF
'put something here
MySet.MoveNext
Loop
DoCmd.SetWarnings True
End Sub
'-------------------------------------

Reply With Quote
  #4  
Old October 20th, 2004, 07:24 PM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 21 h 32 m 23 sec
Reputation Power: 180
I used ADO and JamesLe used DAO, you do need to settle on one database technology to use in code. DAO and ADO are different.

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > Append Query


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 5 hosted by Hostway