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:
  #1  
Old September 30th, 2003, 06: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, 07: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: 8
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





 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

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





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek