Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Problem In Defining Recordset

Status
Not open for further replies.

BenSC

Technical User
Jul 24, 2001
43
GB
Dear All,
I have the following problem, which I am really stumped on. I have a database to store details of building projects, which can be funded from one or more budgets and also have a financial year attached to them. On my data entry form I want to enter the relevant data and have access automatically provide me with a project reference in the following format:

Single Funded Project - ACC-04/05-01. If this reference already existed then I would want access to return ACC-04/05-02 and so on.

Multi-Funded Project - ACC/AMPC-04/05-01. If this reference already existed then I would want Access to return ACC/AMPC-04/05-02 and so on.

I have the following code running on a timer event and can't figure out how to get the recordset to select only the projects which match the budget (e.g. the ACC- part). I am ok with restricting the records returned for the financial year because that is a seperate field.

If anyone could help me with this I'd be very grateful.

Many Thanks

Ben Cooper

------------------------------------------------------

On Error Resume Next

Dim strFunding As String
Dim rst As Recordset
Dim strProjectCount As String

Me.TotalACCAllocation = Me.ACCAllocation0203 + Me.ACCAllocation0304 + Me.ACCAllocation0405 + Me.ACCAllocation0506
Me.TotalAMPCAllocation = Me.AMPCAllocation0203 + Me.AMPCAllocation0304 + Me.AMPCAllocation0405 + Me.AMPCAllocation0506
Me.TotalAMPSAllocation = Me.AMPSAllocation0203 + Me.AMPSAllocation0304 + Me.AMPSAllocation0405 + Me.AMPSAllocation0506
Me.TotalCRFCAllocation = Me.CRFCAllocation0203 + Me.CRFCAllocation0304 + Me.CRFCAllocation0405 + Me.CRFCAllocation0506

If Me.TotalACCAllocation > 0 Then
If Len(strFunding) > 0 Then
strFunding = strFunding & "/ACC"
Else
strFunding = "ACC"
End If
Else
End If
If Me.TotalAMPCAllocation > 0 Then
If Len(strFunding) > 0 Then
strFunding = strFunding & "/AMPC"
Else
strFunding = "AMPC"
End If
Else
End If
If Me.TotalAMPSAllocation > 0 Then
If Len(strFunding) > 0 Then
strFunding = strFunding & "/AMPS"
Else
strFunding = "AMPS"
End If
Else
End If
If Me.TotalCRFCAllocation > 0 Then
If Len(strFunding) > 0 Then
strFunding = strFunding & "/CRFC"
Else
strFunding = "CRFC"
End If
Else
End If

Set rst = CurrentDb.OpenRecordset("SELECT tblProject.* FROM tblProject WHERE tblProject.FinancialYear = '" & Me.FinancialYear & "'")

If rst.EOF Then
strProjectCount = "01"
Else
rst.MoveLast
strProjectCount = rst.RecordCount + 1
End If

If strProjectCount < 10 And Mid(strProjectCount, 1, 1) <> "0" Then
strProjectCount = "0" & strProjectCount
Else
End If

Me.ProjectRef.Value = strFunding & "-" & Me.FinancialYear & "-" & strProjectCount

End Sub
 
I'm not sure I understand the question; I especially don't understand the use of the timer event, but are you looking for something like:

where left(reference,len(strbudget)) = strbudget
 
A little further detail as to what your desired outcome, and what the inputs are would go a long way to getting the info you're looking for.

Stephen [infinity]
"Jesus saith unto him, I am the way, the truth, and the life:
no man cometh unto the Father, but by me." John 14:6 KJV
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top