I have a form that I want to automatically fill in information on.
When the LeaseNumber field is equal to the PrevLeaseNumber field, I want to fill in LeaseName and Location with DLookup or some other action that would retrieve them from the previous record.
Should I use a macro? SQL? An OnUpdate event?
4 3023
In the After Update event of the LeaseNumber field control. -
-
Public Sub LeaseNumber_AfterUpdate()
-
-
If Me.LeaseNumber = Me.PrevLeaseNumber Then
-
Me.LeaseName = Dlookup("[LeaseName]","TableName","[LeaseNumber]=" & Me.LeaseNumber)
-
Me.Location = Dlookup("[Location]","TableName","[LeaseNumber]=" & Me.LeaseNumber)
-
End If
-
-
End Sub
-
-
or if LeaseNumber is a text field then: -
-
Public Sub LeaseNumber_AfterUpdate()
-
-
If Me.LeaseNumber = Me.PrevLeaseNumber Then
-
Me.LeaseName = Dlookup("[LeaseName]","TableName","[LeaseNumber]='" & Me.LeaseNumber & "'")
-
Me.Location = Dlookup("[Location]","TableName","[LeaseNumber'" & Me.LeaseNumber & "'")
-
End If
-
-
End Sub
-
-
In the After Update event of the LeaseNumber field control. -
-
Public Sub LeaseNumber_AfterUpdate()
-
-
If Me.LeaseNumber = Me.PrevLeaseNumber Then
-
Me.LeaseName = Dlookup("[LeaseName]","TableName","[LeaseNumber]=" & Me.LeaseNumber)
-
Me.Location = Dlookup("[Location]","TableName","[LeaseNumber]=" & Me.LeaseNumber)
-
End If
-
-
End Sub
It is a number type. I went into the AfterUpdate and pasted the code, but nothing happened like I wanted. I hit the "Code Bulder" option and it automatically created the lines -
Option Compare Database
-
Public Sub Lease_Number_AfterUpdate()
-
-
End Sub
-
And I pasted the middle section in and tried that.
Now, it gives me a compile error: Method or data member not found.
It also highlights the "Public Sub..." line. it selects the ".LeaseNumber" bit too.
okay, I'm an idiot. I forgot to replace "TableName" with the name of my table, Products1. And I replaced the "." in each line with "!" and it works great now.
Thanks for the help!
Here's what I ended up with: -
Option Compare Database
-
Public Sub Lease_Number_AfterUpdate()
-
-
If Me!LeaseNumber = Me!PrevLeaseNumber Then
-
Me!LeaseName = DLookup("[LeaseName]", "Products1", "[LeaseNumber]=" & Me!LeaseNumber)
-
Me!Location = DLookup("[Location]", "Products1", "[LeaseNumber]=" & Me!LeaseNumber)
-
End If
-
-
End Sub
LeaseNumber is Lease_Number on the form.
Public Sub Lease_Number_AfterUpdate()
If Me.Lease_Number = Me.PrevLeaseNumber Then
Me.LeaseName = Dlookup("[LeaseName]","TableName","[LeaseNumber]=" & Me.Lease_Number)
Me.Location = Dlookup("[Location]","TableName","[LeaseNumber]=" & Me.Lease_Number)
End If
End Sub
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Bob |
last post by:
ok i have a program tah randomizes number adn signs (+,-). i made it
so little kids can learn math easily and i wouldn't have to write each
question out.
when the plus sign is used, eveyrthing...
|
by: shank |
last post by:
I'm coming from the ASP worl and have no clue to javascript. In the
following code, I'm trying to set the value for variable strPage, then use
that in the redirect statement. The page does nothing....
|
by: mallyonline |
last post by:
I last posted to this group about 6 months ago and was very pleased by the
excellent response I got and the great help offered to me. I am back this
time with another request for your expert help...
|
by: Prakash Wadhwani |
last post by:
Hi !! I have been browsing around but have not been able to find a
simple, lucid solution ... or maybe I'm just too confused. I know this
has been asked before by many ... but pls bear with me.
...
|
by: misscrf |
last post by:
I have a search form that is great. I have modified it in such a way,
that when search results come up I can bring it back to a useful spot,
say an entry form or a report.
Here is my lemon (...
|
by: louise raisbeck |
last post by:
I have this scenario (simplified)
function addnewdata () {
check for partial match already in db for information entered by user
if (partialmatch succeeds) {
open new window aspx page (using...
|
by: Amy |
last post by:
Hi,
I have 6 If Then Else statements I was supposed to write. I did so but I
know that they have to be wrong because they all look the same. Could
someone take a look at them and point me in the...
|
by: Knick via AccessMonster.com |
last post by:
I am novice to MS Access Development,
I regularly back my access database every 2, 3 days ...today when I was
going to back my database I saw the access file on the network drive was only
9 MB...
|
by: Vernon Wenberg III |
last post by:
I'm not really sure how readline() works. Is there a way to iterate
through a file with multiple lines and then putting each line in a
variable in a loop?
|
by: jzakiya |
last post by:
I'm translating a program in Python that has this IF Then chain
IF x1 < limit: --- do a ---
IF x2 < limit: --- do b ---
IF x3 < limit: --- do c ---
.-----
------
IF x10 < limt: ---...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |