VBA Help Required Please!

NewbieUK

Registered User.
Local time
Today, 13:05
Joined
Aug 17, 2010
Messages
29
Hi Everyone,

I am trying to get a database working that was written by an old colleague of mine and worked perfectly well on Access 2000. I am now working on Access 2003 and part's of the database are no longer working, I presume because of the new version??

There seems to be a common point in which things are failing to work and is around VBA code that contains me.datelogged.value, example below:

frmCustomerdetails runs the following code on load and gets stuck at highlighted text:

Private Sub Form_Load()
Dim D As Date
Dim rst As Recordset, strCriteria As String
strCriteria = "[JobNumber] = " & gJobNumber
Set rst = Me.RecordsetClone
rst.FindFirst strCriteria
If rst.NoMatch Then
Debug.Print "frmCustomerDetails: No entry found"
Me.Bookmark = rst.Bookmark 'Temp
Else
Me.Bookmark = rst.Bookmark
End If

' Set date
D = rst!Job_DateLogged
If Not IsNull(D) Then
Me.DateLogged.Value = D
Else
Me.DateLogged = Now
End If
StageID = 1

SetMarginText (StageID)
End Sub


I am in no way a VBA whiz so bit stumped as to what is making this fall over? I've checked my references and it's not flagging any up as missing.

Any ideas anyone? Can anyone tell me what this bit of code actually does?
 
Code:
' Set date
[COLOR=Red]D = rst!Job_DateLogged[/COLOR]
If Not IsNull(D) Then
Me.DateLogged.Value = D

I would put a debugger break point on that line in red, use stepped execution (F8), and be sure to put a Watch on variable D to see what is inside it, what data type it is, etc...

Please report back with your findings.
 
Last edited:
Hi,

Thanks for your reply, after playing about some more I think the above code isn't the root course of the error.

I've been trying to trace it back to true break point but I'm having no luck at the moment.

The database contains a lot of VBA and it's all very advanced in terms of my knowledge.

i wonder if you know of any sites or people who would offer to take a look at the database for me?

Thanks
 

Users who are viewing this thread

Back
Top Bottom