Cannot Find Project or Library

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to work on a project that I did not design. The people who did
it are supposed to be professionals, but I think every "Best Practice" ever
listed was violated in this project. Right now, there is a procedure that is
opening a query, which has a field called "DateCreated". Yet, when I try to
run it, it halts on a line that with rst!DateCreated that is trying to
concatenate that field with another. It's not a References problem, as that
error generally indicates. I'm pulling my hair our here. Any and all input
is appreciated.

Thanks
 
DateCreated is a property name for some objects. If you use this name, you
will have to bracket it so Access knows it is a field name and not a property.
 
Or, replace

rst!datecreated

with

rst.Fields("datecreated")
OR
rst("DateCreated")



Chris Nebinger
 
It's CreatedDate, but putting brackets around it didn't help. I agree with
using proper naming conventions. Again, I didn't write this. I'd love to
re-write it from scratch, but don't know that the client is willing to pay
for it.
 
=?Utf-8?B?Qm9iIFdoaXRlaGVhZCwgTUNTRA==?=
Right now, there is a procedure that is
opening a query, which has a field called "DateCreated". Yet, when I
try to run it, it halts on a line that with rst!DateCreated that is
trying to concatenate that field with another

What is the actual code?


Tim F
 
Tim,

The entire procedure is:

Private Sub List2_Click()
On Error Resume Next
Dim custid As Long
custid = DLookup("[id]", "[Customers]", "[HomePhone]='" &
List2.ItemData(List2.ListIndex) & "'")

' Dim strSQL As String
' strSQL = "SELECT * FROM 'Invoices Query' WHERE customerid=" & custid
Dim dbs As Database
Dim rst As Recordset
Set dbs = CodeDb
Set rst = dbs.OpenRecordset("Invoices Query")
rst.MoveFirst
Dim x As Integer
If List9.ListCount > 0 Then
For x = List9.ListCount To 0 Step -1
List9.RemoveItem x - 1
Next
End If

Do While Not rst.EOF
If rst!customerid = custid Then
strTemp = rst!invoicenumber & ";" & rst![CreatedDate]
List9.AddItem strTemp
End If
rst.MoveNext
Loop
'L ist2.AddItem arr!customerid
End Sub

Please remember that I did not write this. As I said in a previous post, I
think every "Best Practice" in the books was violated with this application,
such as naming controls. But I'm just trying to get it to work for this
client while not re-writing the whole thing.

THanks so much for your help.

Bob
 
The only thing that jumps out at me is a difference between the field name in
the code and the field name in your original post.
OP: DateCreated
Code: CreatedDate

I don't know if that is an issue or not.

Bob Whitehead said:
Tim,

The entire procedure is:

Private Sub List2_Click()
On Error Resume Next
Dim custid As Long
custid = DLookup("[id]", "[Customers]", "[HomePhone]='" &
List2.ItemData(List2.ListIndex) & "'")

' Dim strSQL As String
' strSQL = "SELECT * FROM 'Invoices Query' WHERE customerid=" & custid
Dim dbs As Database
Dim rst As Recordset
Set dbs = CodeDb
Set rst = dbs.OpenRecordset("Invoices Query")
rst.MoveFirst
Dim x As Integer
If List9.ListCount > 0 Then
For x = List9.ListCount To 0 Step -1
List9.RemoveItem x - 1
Next
End If

Do While Not rst.EOF
If rst!customerid = custid Then
strTemp = rst!invoicenumber & ";" & rst![CreatedDate]
List9.AddItem strTemp
End If
rst.MoveNext
Loop
'L ist2.AddItem arr!customerid
End Sub

Please remember that I did not write this. As I said in a previous post, I
think every "Best Practice" in the books was violated with this application,
such as naming controls. But I'm just trying to get it to work for this
client while not re-writing the whole thing.

THanks so much for your help.

Bob
--
Bob Whitehead, MCSD
Pensacola, FL
Bob@bobwhitehead-dot-com


Tim Ferguson said:
=?Utf-8?B?Qm9iIFdoaXRlaGVhZCwgTUNTRA==?=


What is the actual code?


Tim F
 
I got it wrong in my orignal post. The code is what it is. And that's what's
throwing the error.
--
Bob Whitehead, MCSD
Pensacola, FL
Bob@bobwhitehead-dot-com


Klatuu said:
The only thing that jumps out at me is a difference between the field name in
the code and the field name in your original post.
OP: DateCreated
Code: CreatedDate

I don't know if that is an issue or not.

Bob Whitehead said:
Tim,

The entire procedure is:

Private Sub List2_Click()
On Error Resume Next
Dim custid As Long
custid = DLookup("[id]", "[Customers]", "[HomePhone]='" &
List2.ItemData(List2.ListIndex) & "'")

' Dim strSQL As String
' strSQL = "SELECT * FROM 'Invoices Query' WHERE customerid=" & custid
Dim dbs As Database
Dim rst As Recordset
Set dbs = CodeDb
Set rst = dbs.OpenRecordset("Invoices Query")
rst.MoveFirst
Dim x As Integer
If List9.ListCount > 0 Then
For x = List9.ListCount To 0 Step -1
List9.RemoveItem x - 1
Next
End If

Do While Not rst.EOF
If rst!customerid = custid Then
strTemp = rst!invoicenumber & ";" & rst![CreatedDate]
List9.AddItem strTemp
End If
rst.MoveNext
Loop
'L ist2.AddItem arr!customerid
End Sub

Please remember that I did not write this. As I said in a previous post, I
think every "Best Practice" in the books was violated with this application,
such as naming controls. But I'm just trying to get it to work for this
client while not re-writing the whole thing.

THanks so much for your help.

Bob
--
Bob Whitehead, MCSD
Pensacola, FL
Bob@bobwhitehead-dot-com


Tim Ferguson said:
=?Utf-8?B?Qm9iIFdoaXRlaGVhZCwgTUNTRA==?=

Right now, there is a procedure that is
opening a query, which has a field called "DateCreated". Yet, when I
try to run it, it halts on a line that with rst!DateCreated that is
trying to concatenate that field with another

What is the actual code?


Tim F
 
=?Utf-8?B?Qm9iIFdoaXRlaGVhZCwgTUNTRA==?= <Bob@vbobwhitehead-dot-
com.donotspam> wrote in @microsoft.com:
Private Sub List2_Click()
On Error Resume Next

This line will screw up any kind of debugging you try -- get rid of it.
If you need some custom error handling, then put in a proper error
handling procedure. Right now, how do you _what_ line is causing an
error?

Dim custid As Long
custid = DLookup("[id]", "[Customers]", _
"[HomePhone]='" & List2.ItemData(List2.ListIndex) & "'")

Dim dbs As Database
Dim rst As Recordset
Set dbs = CodeDb
Set rst = dbs.OpenRecordset("Invoices Query")
rst.MoveFirst

This line is unneccesary and will raise an error if it's an empty
recordset
Dim x As Integer
If List9.ListCount > 0 Then
For x = List9.ListCount To 0 Step -1
List9.RemoveItem x - 1
Next
End If

This whole section has been superceded by the ListBox.Clear method (see
below).
Do While Not rst.EOF
If rst!customerid = custid Then
strTemp = rst!invoicenumber & ";" & rst![CreatedDate]

The variable strTemp is not declared or initialised as far as I can see.
If you are not using Option Explicit then switch it on for all modules
RIGHT NOW. Also put in a proper Dim strTemp As String and strTemp = ""
Second, I would check the names of both of these column names against the
actual contents of the "Invoices Query" querydef.
List9.AddItem strTemp

If you have modern enough version of Access to use ListBox.AddItem, then
it should also have a ListBox.Clear In the old days, we had to make do
with splicing values into the RowSource string. You may as well use the
up to date shortcuts.
End If
rst.MoveNext
Loop
End Sub

Okay... but this seems a very long way round just to bind a recordset to
a list box. What about putting together a proper query and binding the
RowSource to it?

Best of luck


Tim F
 
Back
Top