473,383 Members | 1,742 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,383 software developers and data experts.

Save Record & Add 2 more Records with 1 Field Changed.

I have a form that saves a diet order for a patient in an "Order Detail" table. Presently it saves one record for one particular meal (breakfast, lunch or dinner).

Management now wants 3 records (breakfast, lunch, dinner) saved for each order from the same form.

How do I save two more records with all the data the same except for the one field "meal", which will need to be changed to "2" and "3" for lunch and dinner, respectively?

Currently the information in the form is save to the "Order Detail" table with the follwing: "DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70"

Thanks!!!
Jul 28 '07 #1
3 1460
maxamis4
295 Expert 100+
I sort of understand what your saying but i need more details. Per say why would you want to reference two other meals in the day if you are focusing on meal ticket when you take the order, or are you taking the order for the day and your management wants this so you don't have to enter so much data. Let me know.

thanks
Jul 28 '07 #2
I sort of understand what your saying but i need more details. Per say why would you want to reference two other meals in the day if you are focusing on meal ticket when you take the order, or are you taking the order for the day and your management wants this so you don't have to enter so much data. Let me know.

thanks
Does this matter as to how to do what I need to do?
Jul 29 '07 #3
missinglinq
3,532 Expert 2GB
Reading your post, it sounds as if you want 3 records per patient per day. If this is so, I have to tell that this doesn’t sound like good db design, but it's really hard to tell, since you apparently have a problem giving us clarifying information when it's requested. Be that as it may, this code will accomplish your task as stated.

This code depends on the new record(s) being saved by this code only! You’ll have to set up a trap in the sub Form_BeforeUpdate to prevent the user from moving to another record or closing the form without either saving the 3 new records (I’d put the “save” code in a button, myself) or dumping the new records. Something like
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_BeforeUpdate(Cancel As Integer)
  2.    response = MsgBox("Do You Wish To Save This Record?", vbQuestion + vbYesNo)
  3.  End If
  4.  
and then setting up actions to handle their response, telling them to click on the save button or else dump the new records.

Note that for this code to function properly, you should set the the MealCode textbox to Locked = Yes. The code itself fills in the MealCodes. This code assumes that the MealCode field is Text. If it’s Numeric, replace the Me.MealCode = "1" with Me.MealCode = 1.

replace your code
Expand|Select|Wrap|Line Numbers
  1. DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
  2.  
with this

Expand|Select|Wrap|Line Numbers
  1. Me.MealCode = "1"
  2.  DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
  3.  DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
  4.  DoCmd.DoMenuItem acFormBar, acEditMenu, 5, , acMenuVer70 'Paste Append
  5.  
  6.  Me.MealCode = "2"
  7.  DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
  8.  DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
  9.  DoCmd.DoMenuItem acFormBar, acEditMenu, 5, , acMenuVer70 'Paste Append
  10.  
  11.  Me.MealCode = "3"
  12.  DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
  13.  DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
  14.  DoCmd.DoMenuItem acFormBar, acEditMenu, 5, , acMenuVer70 'Paste Append
  15.  
  16.  Me.Undo
  17.  
Line # 16 removes the new records' data from the control, since it's already been saved at this point, and prepares the form for entering the next patient's info.

You'll have to do some tweaking with the messageboxes for the Form_BeforeUpdate event, but the append code has been tested and works.

Linq
Jul 29 '07 #4

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

Similar topics

8
by: mark | last post by:
Access2000 How do I write a query that combines the CTC field from each record below into one record? I need to concatenate the CTC field with a separator, like below: ...
15
by: Steve | last post by:
I have a form with about 25 fields. In the BeforeUpdate event of the form, I have code that sets the default value of each field to its current value. For a new record, I can put the focus in any...
6
by: Prakash | last post by:
Hi !! In a Continuous Form with say 10 records, I'd like to have 1 button with an "UP" Arrow & another button with a "DOWN" arrow. By pressing either the Up or the Down Arrow, I'd like the user...
2
by: josephm | last post by:
Hello Group: My first post on the group.Hope I get a response. I have a modest Fire Insurance ACCES Db.Thanks to this group - for the code. A "wanna be programmer"... "LEARNS" The code...
1
by: rdraider | last post by:
Hi all, We have an app that uses SQL 2000. I am trying to track when a code field (selcode) is changed on an order which then causes a status field (status) to change. I tried a trigger but...
1
by: David | last post by:
Hi, I have a continuous form with 'x' amount of records. 1 field on each record is a number, of which I have a field at the top of the form which just shows the running sum. If I enter a new...
5
FOE2272
by: FOE2272 | last post by:
I have tried every option that I can think of and most of them on this forum. The closest that I got was to bring up the field but it changed the other records based on what was chosen in one...
4
by: Whasigga | last post by:
Hi I've created a form that has 7 subforms. It is the same subform, bound to a table, just repeated. This form represents a week, and each subform is used to enter in data for each day of the...
7
by: Neil | last post by:
Was working in A2003 and noticed that the Save Record item on the Records menu was not available when the record was not dirty. In A2000, Save Record was always available. (This is a problem for me...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
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...

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.