Hi, I've got a form that allows a user to imput their flight data. I programmed a MsgBox into the save button that asks if the user wants to input another duty position for the flight.
If no, the record saves and the formresets for the next rocord input.
If yes, the record is saved and the duty position and mode of flight fields are set to null, with the remainder of the fields retaining the data already entered.
The problem is that when I press save again, the message box appears, and when I press yes or no I get the 'Save Record' not available error message.
Code attached. Any ideas? - Private Sub Command38_Click()
-
On Error GoTo Err_Command38_Click
-
-
Response = MsgBox("Add another duty position?", 4)
-
If Response = 7 Then
-
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
-
DoCmd.GoToRecord , , acNewRec
-
Else
-
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
-
[PI] = Null
-
[PC] = Null
-
[IP] = Null
-
[SP] = Null
-
[IE] = Null
-
[MTP] = Null
-
[Daytime] = Null
-
[Night] = Null
-
[NVG] = Null
-
[Hood] = Null
-
End If
-
-
Exit_Command38_Click:
-
Exit Sub
-
-
Err_Command38_Click:
-
MsgBox Err.Description
-
Resume Exit_Command38_Click
-
-
End Sub
8 5063 sierra7 446
Recognized Expert Contributor
Hi Scott
Are you by chance using Access 2003 ???
I've found it very prone to chuck-up this error on code which works perfectly in '97 or 2002.
I have not fully bottomed this out , but in some cases if the record has already been saved it will not allow it to be saved a second time (nothing to save?) other times it "thinks" that Allow_Edits=False, because some form is open in Dialogue mode.
However, in passing, I would mention that the syntax you are using is pre-Access'97 and (unless it has changed again with 2007) the preferred syntax is;- - DoCmd.RunCommand acCmdSaveRecord
but I don't think this will resolve your problem.
On a more personal note, I find - Response = MsgBox("Add another duty position?", 4)
-
If Response = 7 Then
-
less easy to read than -
-
Response = MsgBox("Add another duty position?", vbYesNo)
-
If Response = vbNo Then
if I have guessed right, but that is just a matter of preference and will not be the cause of the error message.
If I get time I'll try and set-up a demo and test out your code but I suspect it is more a case of what is open in Access at the time you are trying to Save.
S7
sierra7 446
Recognized Expert Contributor
Hi
I've just re-read your question and I can't understand why you want to "force" a Save in either case.
Access will save automatically on the acNewRecord, so you don't need it there. (Unless you are you using 'Unbound' forms when it won't work anyway)
And I am not too clear why you would want to save on the 'Yes' if the data is incomplete. Why not wait until it is complete? I suspect (and I will have to test this) that if you change the values to Null programatically then the form may not be set to 'Dirty' , so Save may not be available. (having just saved)
Maybe setting
will allow a second save, whether it's needed ot not.
I'm not at my Access2003 machine today but will test on Monday.
S7
Hi S7,
Scott edited the code tags in for me, thanks Scott.
You hit the nail on the head. The record has already been saved; what I can't figure out is how to have it recognize this as a new record without deleting the information out of all the controls. The only controls I want deleted are the ones I null in the code. Any thoughts?
Thanks
I don't want it to save an incomplete record. Here's the situation:
An aviator opens the form to log his flight info.
Once he's done and presses the Save cmdbttn, the msgbox appears asking if he wants to add another duty position for this same flight.
If no, the record is saved and the form resets to add a new record.
If yes, the record saves and then clears only the fields he needs to fill for his second duty position, which keeps him from having to re-enter all the other info.
He then saves this and selects No on the msgbox if no other duty position is required to be filed.
Basicly it creates a new record in the table for each duty position he wants to log.
Josh
I'm heading out the door right now, but I'll look at this further later on today, but one thing that strikes me right off is that your code only shows you moving to a new record once, if you don't want to add another flight position. The way you've described this though, when you add another flight position, you still need to add a new record, just a new record with much of the same data pre-loaded.
In Access you can't simply save a record, delete some of the data from it, then save it again as a new record, like you would a word processor file! The record you're working with is still the original record! You have to move to a new record first, then prefill it with data from the original record, complete it and then save the second record.
Welcome to TheScripts!
Linq ;0)>
I think this is the sort of thing you need: - Private Sub Command38_Click()
-
On Error GoTo Err_Command38_Click
-
-
Response = MsgBox("Add another duty position?", 4)
-
If Response = vbNo Then
-
-
DoCmd.GoToRecord , , acNewRec
-
-
Else 'Add another flight position
-
-
'Assign value of fields you want to carry forward to variables
-
MyFirstField = Me.FirstField
-
MySecondField = Me.SecondField
-
MyThirdField = Me.ThirdField
-
-
'Go to a new record
-
DoCmd.GoToRecord , , acNewRec
-
-
'Plug in old values from variables to new record
-
Me.FirstField = MyFirstField
-
Me.SecondField = MySecondField
-
Me.ThirdField = MyThirdField
-
-
End If
-
-
Exit_Command38_Click:
-
Exit Sub
-
-
Err_Command38_Click:
-
MsgBox Err.Description
-
Resume Exit_Command38_Click
-
-
End Sub
Lines 12-14 copies the value of the fields in the original record that you want to carry forward into the new record into variables. Line 17 moves to a new record. Lines 20-22 re-assigns the variables to the fields in the new record. Any fields that haven't been copied in this manner will be empty, awaiting the new data.
Linq ;0)> sierra7 446
Recognized Expert Contributor
That makes good sense to me Linq!
On the question of differences between 2002 & 2003; have you found that 2003 is more fussy than 2002 in this matter ?
S7
Thanks Linq, that worked like a charm.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Quinn |
last post by:
When users clicked a unkown mime type link such as Zip on my website, a
"Save/Open/Cancel" dialog box pops up. Is there a way to detect which button
users clicked by using ASP? actually I only what...
|
by: J. Koskey |
last post by:
Background: We have hundreds of codes = specific departments, but
there are frequent changes/additions to the info. For users to look
up definitions, we had set up a way in Access to create a...
|
by: Tim |
last post by:
I have used a graphic 'next record' button on a form. How can I stop it
from going past the last existing record? In other words, I don't want it
to take the user to a blank record.
Thanks
Tim
|
by: me |
last post by:
I'm building a multi user app where many admins will be making calls to
people in one table. I want to keep things simple and find a way to prevent
2 or more admins from working on the same record...
|
by: Paul Sullivan |
last post by:
We are a state agency that views protected medical information via our
intranet. The screens even have privacy shields. Alarmingly, uses can
"Print" and "Save As" which destroys the protection of...
| |
by: asenthil |
last post by:
Hai to all,
if i'm having a file named as "tab.doc" which is a microsoft word document file ...
i want to save it as another file as "tab1.doc" by using
"save as" method....
Is there...
|
by: anudu |
last post by:
hi,
I am developing a system with asp.net, c#, and ajax.
I have an excel file in server in "Server.MapPath("ExcelFiles/Test.xls")".
I want to make it available to save to the disk in client...
|
by: tekctrl |
last post by:
Anyone:
I have a simple MSAccess DB which was created from an old ASCII flatfile.
It works fine except for something that just started happening. I'll enter
info in a record, save the record,...
|
by: Edwin.Madari |
last post by:
since choice of dbm used by shelve http://docs.python.org/lib/node327.html depends on os, and whats available on it, shevle files saved on one os, most likely do not work on another os, sometimes on...
|
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,...
|
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...
| |
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: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
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...
|
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...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |