This morning, this code quit working

G

Guest

Private Sub VendorChqNum_AfterUpdate()

Dim DateToUse As Variant

If IsNull(Me.VendorChqDate) And Not IsNull(Me.VendorChqNum) Then
DateToUse = DLookup("[VendorChqDate]", "tblInvoices", "[VendorChqNum]='"
& _
Me.VendorChqNum & "'")
Me.VendorChqDate = DateToUse
' DateToUse = ""

Else: Exit Sub

End If

If Me.NewRecord And IsNull(PONum) Then
PONum = Me.Parent!PONum
Else
End If

End Sub


Has been working for months. Any ideas why this code would "up and quit"?
I haven't changed a thing for weeks.

Thanks.
 
G

Guest

How did it quit? Error message? Not updating things?

Just because you didn't change anything doesn't mean that someone else
didn't. Do you have automatic updates enables? Microsoft often releases bug
fixes and patches on Tuesday evenings. Is your computer a stand-alone or on a
network controlled by IT people?
 
J

Jason Lepack

Define "Quit Working".
Error message? Post it.
Doesn't look like it's doing anything? Have you tried putting a
breakpoint in to see if it's actually getting to the code?
 
G

Guest

Sigh, I'm such a n00b, all excellent questions, Jerry.

In the meantime I looked at the table and found a lot of instances where the
vendor cheq number had been initally entered without a date. So the records
returned later, on the Dlookup, contained a lot of "empties". I updated the
table, and now the code is working. Thanks, Jerry.


Jerry Whittle said:
How did it quit? Error message? Not updating things?

Just because you didn't change anything doesn't mean that someone else
didn't. Do you have automatic updates enables? Microsoft often releases bug
fixes and patches on Tuesday evenings. Is your computer a stand-alone or on a
network controlled by IT people?
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.


Ricter said:
Private Sub VendorChqNum_AfterUpdate()

Dim DateToUse As Variant

If IsNull(Me.VendorChqDate) And Not IsNull(Me.VendorChqNum) Then
DateToUse = DLookup("[VendorChqDate]", "tblInvoices", "[VendorChqNum]='"
& _
Me.VendorChqNum & "'")
Me.VendorChqDate = DateToUse
' DateToUse = ""

Else: Exit Sub

End If

If Me.NewRecord And IsNull(PONum) Then
PONum = Me.Parent!PONum
Else
End If

End Sub


Has been working for months. Any ideas why this code would "up and quit"?
I haven't changed a thing for weeks.

Thanks.
 
P

Pat Hartman \(MVP\)

This makes me think that you are using the wrong function. The Dlookup()
function will return an ARBITRARY record when multiple records match the
selection criteria - check the help entry for details since you may not be
getting what you expect in all cases.
If you are interested in the most recent date for a check number, you should
be using DMax().

Ricter said:
Sigh, I'm such a n00b, all excellent questions, Jerry.

In the meantime I looked at the table and found a lot of instances where
the
vendor cheq number had been initally entered without a date. So the
records
returned later, on the Dlookup, contained a lot of "empties". I updated
the
table, and now the code is working. Thanks, Jerry.


Jerry Whittle said:
How did it quit? Error message? Not updating things?

Just because you didn't change anything doesn't mean that someone else
didn't. Do you have automatic updates enables? Microsoft often releases
bug
fixes and patches on Tuesday evenings. Is your computer a stand-alone or
on a
network controlled by IT people?
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.


Ricter said:
Private Sub VendorChqNum_AfterUpdate()

Dim DateToUse As Variant

If IsNull(Me.VendorChqDate) And Not IsNull(Me.VendorChqNum) Then
DateToUse = DLookup("[VendorChqDate]", "tblInvoices",
"[VendorChqNum]='"
& _
Me.VendorChqNum & "'")
Me.VendorChqDate = DateToUse
' DateToUse = ""

Else: Exit Sub

End If

If Me.NewRecord And IsNull(PONum) Then
PONum = Me.Parent!PONum
Else
End If

End Sub


Has been working for months. Any ideas why this code would "up and
quit"?
I haven't changed a thing for weeks.

Thanks.
 
H

HeliCaptKirk

I too have a problem with Dlookup stopping working for no apparent reason.
I've been working on a DB for months. Finally got it working the way it
should and have been taking it back and forth on a pen drive from work to
home to work on it.

2 days ago, the switchboard function stopped working. The form loads fine,
the user puts his password and user ID in and it's supposed to look up his
permissions.
On my work machine, it works just fine. Now on every other machine I try it
on (including the one at home on which it was partially developed) the
DLookup function returns the "you canceled the previous operation" error
(Runtime error 2001).

I have looked at the references for all machines -they are all identical.
I've copied from one to another (machine) back and forth, compacted and
repaired, and pulled my hair out. The ONLY machine it works on is my laptop
from work.

Help.

Here is the code:
'Determine the user information via lookup table for password and status
LoggedUserNUID = Me.ubUserNUID
UserPassword = DLookup("[Password1]", "tblAccessData", "UserNUID =
LoggedUserNUID")
UserStatus = DLookup("[UserStatus]", "tblAccessData", "[UserNUID] =
LoggedUserNUID")

FYI (setups):
"LoggedUserNUID" is a global variable defined the Module
UserStatus is a public variable defined in the current form
[UserStatus] is the text field in the "tblAccessData" security table

All fields are text.

Oh and this routine worked for weeks without fail. I have NOT changed the
code so I know for a fact it is correct and works.

Any thoughts on why this is happening and how to fix it? I need to
distribute this to my team and can't until this works on their machines.
(Which I tested on Friday and it doesn't). HELP!!!!!
 
D

Douglas J. Steele

I don't understand how that could be working on any machine, as it's
incorrect. The reference to the variable needs to go outside of the quotes:

UserPassword = DLookup("[Password1]", "tblAccessData", "UserNUID = """ &
LoggedUserNUID & """")
UserStatus = DLookup("[UserStatus]", "tblAccessData", "[UserNUID] = """ &
LoggedUserNUID & """")

That's three double quotes in a row in front, and four double quotes in a
row after, although since the logged in user name can never include
apostrophes, you could also use

UserPassword = DLookup("[Password1]", "tblAccessData", "UserNUID = '" &
LoggedUserNUID & "'")
UserStatus = DLookup("[UserStatus]", "tblAccessData", "[UserNUID] = '" &
LoggedUserNUID & "'")

where that's single quote-double quote in front, and double quote-single
quote-double quote after.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



HeliCaptKirk said:
I too have a problem with Dlookup stopping working for no apparent reason.
I've been working on a DB for months. Finally got it working the way it
should and have been taking it back and forth on a pen drive from work to
home to work on it.

2 days ago, the switchboard function stopped working. The form loads
fine,
the user puts his password and user ID in and it's supposed to look up his
permissions.
On my work machine, it works just fine. Now on every other machine I try
it
on (including the one at home on which it was partially developed) the
DLookup function returns the "you canceled the previous operation" error
(Runtime error 2001).

I have looked at the references for all machines -they are all identical.
I've copied from one to another (machine) back and forth, compacted and
repaired, and pulled my hair out. The ONLY machine it works on is my
laptop
from work.

Help.

Here is the code:
'Determine the user information via lookup table for password and status
LoggedUserNUID = Me.ubUserNUID
UserPassword = DLookup("[Password1]", "tblAccessData", "UserNUID =
LoggedUserNUID")
UserStatus = DLookup("[UserStatus]", "tblAccessData", "[UserNUID] =
LoggedUserNUID")

FYI (setups):
"LoggedUserNUID" is a global variable defined the Module
UserStatus is a public variable defined in the current form
[UserStatus] is the text field in the "tblAccessData" security table

All fields are text.

Oh and this routine worked for weeks without fail. I have NOT changed the
code so I know for a fact it is correct and works.

Any thoughts on why this is happening and how to fix it? I need to
distribute this to my team and can't until this works on their machines.
(Which I tested on Friday and it doesn't). HELP!!!!!




Ricter said:
Private Sub VendorChqNum_AfterUpdate()

Dim DateToUse As Variant

If IsNull(Me.VendorChqDate) And Not IsNull(Me.VendorChqNum) Then
DateToUse = DLookup("[VendorChqDate]", "tblInvoices",
"[VendorChqNum]='"
& _
Me.VendorChqNum & "'")
Me.VendorChqDate = DateToUse
' DateToUse = ""

Else: Exit Sub

End If

If Me.NewRecord And IsNull(PONum) Then
PONum = Me.Parent!PONum
Else
End If

End Sub


Has been working for months. Any ideas why this code would "up and
quit"?
I haven't changed a thing for weeks.

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top