Microsoft Access Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseMicrosoft Access Help

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:
Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
  #1  
Old September 30th, 2003, 05:58 AM
kjrooney kjrooney is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 1 kjrooney User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Referencing a Module object within a query

Hi

I have built a database whose primary fuction is to track future staff movement and resourcing.

The database runs a query based upon the variable [DateField], and requires the inputing of a value for [DateField] i need the query to run 80 times, adding 1 day onto the variable [Datefield] each time. script has been written to allow the query to run 80 times, and also defines the value of [DateField] for each of the queries. However this is referenced in the code simply as DateField, and i cannot link it to my Query

Module code:

Private Sub Command0_Click()
Dim cn As ADODB.Connection
Dim rst As ADODB.Recordset
Dim strSQL As String
Dim strQuery As String
Dim newDate As String
Dim mydate As Date
Dim i As Integer

Set cn = New ADODB.Connection
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source = c:\Documents and Settings\ken01.000\My Documents\Staffing Database.mdb"

cn.Open
Set rst = New ADODB.Recordset
With rst
.ActiveConnection = cn
.CursorType = adOpenStatic
.LockType = adLockOptimistic
End With

newDate = "#9/29/2003#"

strQuery = "qryDateTest"

For i = 1 To 79
strSQL = "SELECT * FROM " & strQuery & "" & _
" WHERE DateField = (" & newDate & ")"

rst.Open (strSQL)

'do something with the recordset

mydate = CDate((Mid(newDate, 2, 9)))
mydate = mydate + 1
newDate = "#" & CStr(mydate) & "#"
rst.Close
Next i

End Sub

Query:

SELECT tblStaffReq.PayrollNumber, tblStaffReq.Surname, tblStaffReq.Forename, tblStaffReq.[Fte Coefficient], IIf([tblStaffReq]![Date Effective]<=[DateField],[tblStaffReq]![New Project],[tblStaffReq]![CoreGroup]) AS [Determined Project]
FROM tblStaffReq;

If anyone has any ideas how to reference the Variable New date through the Query, please let me know, and i will be extremely grateful.

Kind Regards
Kenny

Reply With Quote
  #2  
Old October 8th, 2003, 06:27 AM
m_lazor m_lazor is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Luxembourg
Posts: 156 m_lazor User rank is Corporal (100 - 500 Reputation Level)m_lazor User rank is Corporal (100 - 500 Reputation Level)m_lazor User rank is Corporal (100 - 500 Reputation Level)m_lazor User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
A quick shot would be to create a table with the dates and then link it to the rest of the query. That what you need?

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft Access Help > Referencing a Module object within a 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 2 hosted by Hostway