473,395 Members | 1,613 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Auto populate form control on data entry

I have a form called frmIlogEntry. this form is based on the table tblILOG. I have a fields in the table and on the form VendNo and VendName. On the form I want when the user types in the VendNo the field VendName to auto-populate. I am sure this is probably an easy function but for the life of me I can't get it. VendNo and VendName are stored in tblVendors. Please help....AO3
Dec 11 '06 #1
11 3212
MMcCarthy
14,534 Expert Mod 8TB
I have a form called frmIlogEntry. this form is based on the table tblILOG. I have a fields in the table and on the form VendNo and VendName. On the form I want when the user types in the VendNo the field VendName to auto-populate. I am sure this is probably an easy function but for the life of me I can't get it. VendNo and VendName are stored in tblVendors. Please help....AO3
In the After Update event of the control VendNo you can put the following code.

Expand|Select|Wrap|Line Numbers
  1. Private Sub VendNo_AfterUpdate()
  2.  
  3.    Me.VendName = DLookup("[VendName]","tblVendors","[VendNo]=" Me.VendNo
  4.  
  5. End Sub
  6.  
Mary
Dec 11 '06 #2
MMcCarthy
14,534 Expert Mod 8TB
"The title of this thread has been changed to make the problem clearer to experts and others searching for similar threads."

MODERATOR
Dec 11 '06 #3
In the After Update event of the control VendNo you can put the following code.

Expand|Select|Wrap|Line Numbers
  1. Private Sub VendNo_AfterUpdate()
  2.  
  3.    Me.VendName = DLookup("[VendName]","tblVendors","[VendNo]=" Me.VendNo
  4.  
  5. End Sub
  6.  
I copied and pasted this directly as shown and I get a syntax error.
AO3
Dec 11 '06 #4
I copied and pasted this directly as shown and I get a syntax error.
AO3
I have since changed it to look like this now I get a runtime error 2001 You have canceled the previous operation.

Expand|Select|Wrap|Line Numbers
  1.  Private Sub VendNo_AfterUpdate()
  2. Me.VendName = DLookup("[VendName]", "tblVendors", " [VendNo]= Me.VendNo")
  3.  
  4. End Sub 
Dec 11 '06 #5
MMcCarthy
14,534 Expert Mod 8TB
I copied and pasted this directly as shown and I get a syntax error.
AO3
Sorry my error. See the following ...

Expand|Select|Wrap|Line Numbers
  1. Private Sub VendNo_AfterUpdate()
  2.  
  3.    Me.VendName = DLookup("[VendName]","tblVendors","[VendNo]=" & Me.VendNo)
  4.  
  5. End Sub
Mary
Dec 11 '06 #6
Thanks Mary For the assistance!! it worked great.

just a quick question on Dlookup though......Is it possible to Lookup between a range of numbers? in the same form I want to look up an AQL level by the number of samples submitted. i have a table AQL with MinSamp and MaxSamp. i have replicated the info you gave me earlier using the following
Expand|Select|Wrap|Line Numbers
  1.  Private Sub RecQTY_AfterUpdate()
  2. Me.ReqAQL = DLookup("[ReqAQL]", "tblAQL", "[SampMin]>=" & Me.RecQTY)
  3.  
  4. End Sub 
however I keep getting inaccurate results unless I type in the specific number in SampMin. the table is as specified

SampMin SampMax ReqAQL
1 1 1
2 8 2
9 15 3
16 25 5


so on and so forth. If I type in 9 in RecQTy then ReqAQL populates with 3 but if i type in 10 then it populates with 5. I know in excel how I would do this....unfortunately this is not excel. Thanks for any help you can provide. I am just a newbie and I apologize if I am annoying.
Dec 12 '06 #7
MMcCarthy
14,534 Expert Mod 8TB
Try this ...

Expand|Select|Wrap|Line Numbers
  1. Private Sub RecQTY_AfterUpdate()
  2.  
  3.    Me.ReqAQL = DLookup("[ReqAQL]", "tblAQL", "[SampMin]>=" & Me.RecQTY & " AND " & Me.RecQTY & "<=
  4. [SampMax]")
  5.  
  6. End Sub 
  7.  
Mary
Dec 12 '06 #8
Nope..... it still returns the wrong number...unless I am doing something wrong.. When I copied and pasted I had one too many quotation marks at the end of the statement so I deleted them and it would compile. if I type the exact SampMin then I get the correct number but anything in the range up to the next SampMin I get the next value up in the sequence as before.
Dec 12 '06 #9
MMcCarthy
14,534 Expert Mod 8TB
It's definately not the last quotation mark. Did you copy and paste it exactly as it is below?

Expand|Select|Wrap|Line Numbers
  1. Private Sub RecQTY_AfterUpdate()
  2.  
  3.    Me.ReqAQL = DLookup("[ReqAQL]", "tblAQL", "[SampMin]>=" & Me.RecQTY & " AND " & Me.RecQTY & "<=
  4. [SampMax]")
  5.  
  6. End Sub 
  7.  
Dec 12 '06 #10
I copied and pasted exactly as below

Expand|Select|Wrap|Line Numbers
  1.  Private Sub RecQTY_AfterUpdate()
  2.  
  3.      Me.ReqAQL = DLookup("[ReqAQL]", "tblAQL", "[SampMin]>=" & Me.RecQTY & " AND " & Me.RecQTY & "<=[SampMax]")
  4.  
  5. End Sub
Table data is as follows

SampMin SampMax ReqAQL
2 8 2
9 15 3
16 25 5
26 50 8
51 90 13
91 150 20
151 280 32
281 500 50
501 1200 80
1201 3200 125
3201 10000 200
10001 35000 315
35001 150000 500
150001 500000 800
500001 999999999 1250
1 1 1

When I type 280 in RecQTY the result is 50 and should be 32. if I type 279 I get 50. If I type 151 I get 32.....

AO3
Dec 12 '06 #11
MMcCarthy
14,534 Expert Mod 8TB
Try this ...

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub RecQTY_AfterUpdate()
  3.  
  4.    Me.ReqAQL = DLookup("[ReqAQL]", "tblAQL", "[SampMin]<=" & Me.RecQTY & " AND [SampMax]>=" & Me.RecQTY)
  5.  
  6. End Sub
  7.  
Mary
Dec 12 '06 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: ogilby1 | last post by:
Using an immediate if to fill a field on a form based on the value of another field. During data entry on the form this methodology works well. When looking at the results in the datasheet view or...
2
by: SalimShahzad | last post by:
Dear Gurus, i had written following codes to auto generate the next claim no Private Const strC = "GCT/02/J/" Private Sub Command1_Click() Dim stra, stre As String Dim intb, intd As Integer...
2
by: des-sd | last post by:
Access Experts, Please help! I have looked through ref. manuals, Google Groups on "Auto Populate", and I am still lost. Problem #1 My DB is 2 relational tables of (1) sales transactions of,...
4
by: whamo | last post by:
I have the need to populate a field based on the selection in a combo box. Starting out simple. (2) tables tbl_OSE_Info and tbl_Input; tbl_OSE_Info has three fields: Key, OSE_Name and OSE_Wt...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
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,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.