Hi John, sorry to be so long in coming back to you but is there a way of
"Aborting" the saving of the new record? Going back to my earlier notes, I
have a load of Text Boxes tha are "Bound " to the appropriat fields in the
Customers Table. These Text Boxes are great for finding and displaying
records in the table but any user will, at some time, want to add new
records
to the table. The way I have approached this in the past is to generate a
parallel set of "Unbound" Text Boxes and use these to gather the new
record
information. I then follow this by writing out the contents of each
individual "Unbound Text Box to a new record in the table using the "Save
record" routine I set out at the begining of my query after first asking
the
user if they want to Save the data or Abort. I can also check for required
fields and prompt the user if any are not completed correctly. Your
solution
is great in that it allows me to work with only one set of "Bound" text
boxes. However, the solution does seem somewhat flawed to me in that the
user
says that they want to Add a New Record but there is no method by which
the
user can subsequently say that they have made a mistake and have the
option
not to save "Duff" information. Am I missing something here?
Your help is very much appreciated. RayC
:
Actually, it should save automatically. Access does that. I can't
remember why I put that bit in there - probably paranoia on my part.
'====================================================
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
'====================================================
Ray C wrote:
Ahh, interesting, I will try to remember that.
With regard to your excelent solution to my problem, do I need to have
something that will save the record or will it save automatically.
Also,
should I not be putting something in there that asks the user if they
want to
save or not?
Regards RayC
:
The dirty bit forces a save of the current record if it has not yet
been
saved.
'====================================================
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
'====================================================
Ray C wrote:
Thanks John I will give it a try. Cureous about the "Dirty" bit
though.
I realy appreciate your help. RayC
:
Add a button to your form "New Record"
In the click event add code to go to NEW Record.
THe code you need to add for the buttons click event should look
something like
On Error GoTo Err_sCmdAdd
With Me
If .Dirty = True Then .Dirty = False
If .AllowAdditions = False Then
.AllowAdditions = True
End If
DoCmd.GoToRecord , , acNewRec
End With
Exit_sCmdAdd:
Exit Function
Err_sCmdAdd:
MsgBox Err.Number & ": " & Err.Description,
'====================================================
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
'====================================================
Ray C wrote:
It's only confusing because You know what I should be diong and I
don't know
what I am doing
I have a Form and I have Text Boxes on thst Form that are "Bound"
to fields
in a Table. This is great if all I want to do is look at the
information in
that Table but I might want to add a new record at some time and it
is this
that I am working my way through. I don't have navigation Buttons
on my Form
so I am not able to go to the last record and enter new information
then
save. Could I do that under program control?
Hope this helps RayC
:
What are you trying to do? Sounds very confused to me.
--
The 11th day of every month:
http://truthaction.org/forum/index.php
:
I have a number of "Bound" Text Boxes that display the
appropriate records in
a Table (e.g. Mame, Address, etc) but I will want to add new
records at some
time and I also Duplicate those same Text Boxes and have them
"Unbound" so
that I can enter new info into them. I then I write that data to
a new record
by using the following :- where ****TxtBox is the "Unbound" Text
Box.
Private Sub SaveRecord()
Dim db As Database, rs1 As Recordset
Set db = CurrentDb
Set rs1 = db.OpenRecordset("tbl_Customer", dbOpenDynaset)
rs1.MoveLast
With rs1
.AddNew ' Add new record to end of
Recordset
Object.
![Name] = NameTxtBox
![Addr1] = Addr1TxtBox
![Addr2] = Addr2TxtBox
Etc, Etc
.Update
End With
rs1.Close: db.Close
End Sub
If I could change the Text Box under Program control, it would
save
duplicating all those extra boxes.
Or is there a better way to do it?
Thanks RayC