473,732 Members | 2,214 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Set a Value on a form's bound field based on field in separate table

67 New Member
Using attached database. Open Form "DH ADD ORDERS w/Tax". I would like to autopopulate the bound control "INVNUM". It's source would be the field INVNUM in the table INVOICE.
I was hoping to use a SetValue Macro, using a DMAX expression to set the value.
Problem is that INVOICE contains some very old INVNUM above 900,000. I want to pick up where the current INVNUM end at 46822, so my next INVNUM would be 46823.
I think I need to couple a Where statement in my expression, but am not sure how to do it.
In essence it would say, "Set Value of INVNUM on the form at a value one greater than the greatest INVNUM in the Table INVOICE that is below 900,000.
Any suggestions?
Thanks
Attached Files
File Type: zip TEST DB II.zip (254.1 KB, 163 views)
Jul 19 '10 #1
20 5770
NeoPa
32,569 Recognized Expert Moderator MVP
What data source is the form bound to?
And what is the name of the control where the invoice number is displayed?

The trick involves setting the Default value of the control, so that it is only used if data is added to the form.
Jul 20 '10 #2
Bigdaddrock
67 New Member
@NeoPa
The form in question is bound to the a query DH INVOICE Query (perhaps I should change this and bind the form directly to the Table INVOICE?). The control on the form is INVNUM.
Thanks for your continuing assistance.
Jul 20 '10 #3
NeoPa
32,569 Recognized Expert Moderator MVP
You can probably use the INVOICE table anyway for this.
Expand|Select|Wrap|Line Numbers
  1. Private Form_Load()
  2.   Me.INVNUM.Default = DMax("[INVNUM]", _
  3.                            "[INVOICE]", _
  4.                            "[INVNUM]<900000") + 1
  5. End Sub
You may need to change the value when new items are added too. It depends on how the form is used.
Jul 20 '10 #4
Bigdaddrock
67 New Member
When I attempt to put in a new [Event Procedure] I am immediately shown the following:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2.  
  3. End Sub
I tried inserting all of the lines of code you suggested, but it failed. I then attempted to drop your first and last lines: Private Form_Load() and End Sub, and saved the follwing:
Expand|Select|Wrap|Line Numbers
  1. Private Form_Load()
  2.  Me.INVNUM.Default = DMax("[INVNUM]", _
  3.                           "[INVOICE]", _
  4.                           "[INVNUM]<900000") + 1
  5. End Sub
But, alas, it too failed. I get the following message:
Compile Error:
Method or data member not found.

In addition the word "Default" is highlighted in yellow.

Any further suggestions?
Jul 20 '10 #5
NeoPa
32,569 Recognized Expert Moderator MVP
My apologies. It should read :
Expand|Select|Wrap|Line Numbers
  1. Private Form_Load()
  2.   Me.INVNUM.DefaultValue = DMax("[INVNUM]", _
  3.                                 "[INVOICE]", _
  4.                                 "[INVNUM]<900000") + 1
  5. End Sub
Jul 20 '10 #6
Bigdaddrock
67 New Member
GREAT!!! I TRIED IT AND IT DOES INDEED WORK. THANKS SO MUCH FOR YOUR PATIENCE AND WILLINGNESS TO STICK WITH ME WITH THIS ISSUE. I look forward to more interaction with you and the group. You are indeed the best!!
Thanks again!!
Jul 22 '10 #7
NeoPa
32,569 Recognized Expert Moderator MVP
I'm pleased I could help :)
Jul 22 '10 #8
Bigdaddrock
67 New Member
@NeoPa
I would now like to apply the same procedure to another item in a form. However, in the prior instance I used the same field name "INVNUM in the source table and in the form.
In this case I am seeking to have the Default Value of the field Tax with the value associated with a record from a query called "DH Tax Computation Query II".
The field in the query is "SumOfTax", and the specific specific record is the greatest value in the field INVNUM within the same query.
Could you possibly provide the code to do so?
Thanks.
Jul 22 '10 #9
NeoPa
32,569 Recognized Expert Moderator MVP
I could do that, but that would be like fishing for you. I'd rather teach you to fish.

Go give it a try first and I'll help you along if you stumble. Your first step is to put the cursor within the word DMax then press F1 for Context-sensitive help. Read what it says. It makes it clear what is used where, and why. I expect after that you'll understand the code well enough to replicate it for your slightly different circumstances.

Post what you come up with and how pleased you are that it's working and it was all your own doing :)
Jul 22 '10 #10

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

Similar topics

6
148643
by: Steve Speirs | last post by:
Hi I'm trying to show/hide a simple piece of text and a text field on a form based on what choice is made from a drop down box. <select name="dropdown" size="1"> <option selected value="">Please make a selection</option> <option value="1">Choice 1</option> <option value="2">Choice 2</option> <option value="3">Choice 3</option>
2
14930
by: Daniel | last post by:
I use an Access database to basically take data exports, import them, manipulate the data, and then turn them into exportable reports. I do this using numerous macros, and queries to get the data in the format that I need it in order to create the reports that we use. So far this has proven to be successful for the reports that I am doing and the data that I am pulling into it. I just have one challenge that may require a lot of work and I...
4
2227
by: Scott Kinney | last post by:
I have an inventory database. I want to delete out-of-stock items from the main database, but keep them in a separate table so that I can reference data about them. I created a copy of the item table, structure only, no data. Then I query the item table for the ones I want, and attempt to copy them to the out of stock item table. The 'paste' fails all the time. On the theory that the ItemId (Autonumber in the main table) is the culprit,...
1
3441
by: Don Leverton | last post by:
Hi Folks, I have been given a CD with approx 130 .xls files (bean-counters!) that I would like to import and merge to ONE table (tblTradeshow). The XL files are *similarly*, but not identically structured, and the first row does NOT contain field names. Some (actually most) of the column names *are* the same in all of the spreadsheets.
2
4337
by: Mike | last post by:
I'm sure this has been covered before in the newsgroup but have had no luck locating it. I have two tables: InstMonitors & MonModDesc Structure of MonModDesc: Model, Description Structure of InstMonitors: CompName, Make, Model, Description, Serial, PurchDate, WarrExpDate
3
3045
by: EJH | last post by:
I have a Database that has three tables. One of the three is just a table that contains three fields and is filled with reference information. One field is 3-Digit(primary key), the next is Office, and the last is Area. The next table has the same type of headings plus several other fields but is not filled with data. I want to be able to create a form and enter a 3 digit number in the 3-Digit field of the second table and have it...
2
1786
by: Chippy | last post by:
I am having trouble working out how to update a field on an open form with a calculation based upon calculations from other tables! For example, I have 3 tables: Diary Diary_ID: autonum, primary key etc Diary_Date: date/time Diary_CaloriesTotal: number
1
2764
by: Richard | last post by:
Very typical normal data Table One ------ One.OneID (PK) One.Name One.Description One.TwoID (FK) One.ThreeID (FK) ....
4
13970
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 tbl_Input has three fields: OSE_Job, OSE_Name, OSE_Wt I have populated tbl_OSE_Info table. I need to create a form that will store the data in tbl_Input I have racked my brain so much trying to figure out how to auto populate a field based on a...
3
1608
by: ramprat | last post by:
Hi All, I am using Access 2003 and have a continuous form based on a table (table1) as a subform on another form. I simply want to be able to take any records that get added to table1 through the subform and populate a 2nd table (table2) with these added records from the subform the instant they are added. The two tables both contain a common ID field. Also if any values in existing records on the subform change I would like to update a...
0
8946
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8774
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9235
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9181
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8186
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6031
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4809
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2721
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.