473,769 Members | 1,694 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Custom New...Edit...Sa ve buttons

I have a dilema here that I'm hoping some one can help me out with.

On my forms I have some basic New, Edit, Save, Delete, Undo buttons on
them. When first opened all controls on the form are not enabled. When
you hit one of the buttons certain controls enable and some don't
depending on the function. My dilema is with the New button and in turn
the Save button.

I would rather the user click the "New" button to add a record instead
of clicking the next button, or the page down. So the first thing I
tried was to turn the AllowAddtions to Off. Then the first part of my
code when "New" is clicked turns it on, then adds new record. Now the
user would hit the "Save" button to basically set the enable to all
controls to false and then turn the AllowAdditions back off. The
problem is when it turns the AllowAdditions to off, the form jumps back
to record # 1. So I thought I would add code to have it go to the Last
Record after all the other code finished, but that only works on a new
record, if I hit "Save" after editing a record, I wouldn't want it to
jump to the Last record.

I decided to forget about the above method and just go back to allowing
additions, maybe I can fix that later with security settings or
something.

But I found one other annoyance after adding a New Record and then
Saving it. I'm using code for my own custom First, Last, Next, Previous
buttons and a Label that shows the Record x of y info. This always says
New Record until I leave the record and come back.

Is there anyway to have turning off AllowAddtions to not take you to
record # 1 or is there a way to have the Record x of y label not always
say New Record.

Or any other method of doing what I'm looking for.

It's kind of confusing so if you have any questions, ask me.

Thanks,
Ken Mylar

Apr 28 '06 #1
6 4933
Ken Mylar wrote:
I have a dilema here that I'm hoping some one can help me out with.

On my forms I have some basic New, Edit, Save, Delete, Undo buttons on
them. When first opened all controls on the form are not enabled. When
you hit one of the buttons certain controls enable and some don't
depending on the function. My dilema is with the New button and in turn
the Save button.

I would rather the user click the "New" button to add a record instead
of clicking the next button, or the page down. So the first thing I
tried was to turn the AllowAddtions to Off. Then the first part of my
code when "New" is clicked turns it on, then adds new record. Now the
user would hit the "Save" button to basically set the enable to all
controls to false and then turn the AllowAdditions back off. The
problem is when it turns the AllowAdditions to off, the form jumps back
to record # 1. So I thought I would add code to have it go to the Last
Record after all the other code finished, but that only works on a new
record, if I hit "Save" after editing a record, I wouldn't want it to
jump to the Last record.

I decided to forget about the above method and just go back to allowing
additions, maybe I can fix that later with security settings or
something.

But I found one other annoyance after adding a New Record and then
Saving it. I'm using code for my own custom First, Last, Next, Previous
buttons and a Label that shows the Record x of y info. This always says
New Record until I leave the record and come back.

Is there anyway to have turning off AllowAddtions to not take you to
record # 1 or is there a way to have the Record x of y label not always
say New Record.

Or any other method of doing what I'm looking for.

It's kind of confusing so if you have any questions, ask me.

Thanks,
Ken Mylar

When you save the record, store the ID. Then you can have similar code to
Dim rst As Recordset
set rst = Me.RecordsetClo ne
rst.Findfirst "ID = " & lngStoredID
Me.bookmark = rst.Bookmark
This will move you back to the record last added.

Apr 28 '06 #2
Thanks for your help! I'm not sure how to go about storing the ID when
I save the record. I have a bunch of forms that all the same exact
buttons, so I created all my code as a Public Function, so I didn't
have to keep duplicating all the same code. The Save function is shown
below, I hope this can work on a global level because it sounds like
exactly what I need. If not, I may need to take the Save function down
to form level.

Thanks,
Ken
*************** *************** *************** *************** *************** ****
Public Function cmdSave_Click(f rm As Form)
On Error GoTo Err_cmdSave_Cli ck

Dim ctl As Control

For Each ctl In frm.Controls
If ctl.Tag = "Unlockable " Then
ctl.Enabled = False
ElseIf ctl.Tag = "AlwaysLock ed" Then
ctl.Enabled = False
End If
Next ctl

DoCmd.RunComman d acCmdSaveRecord

frm.cmdFirst.En abled = True
frm.cmdPrevious .Enabled = True
frm.cmdNext.Ena bled = True
frm.cmdLast.Ena bled = True
frm.cmdClose.En abled = True
frm.cmdEdit.Ena bled = True
frm.cmdNew.Enab led = True
frm.cmdDelete.E nabled = True
frm.btnUndo.Ena bled = False
frm!cmdEdit.Set Focus
frm.cmdSave.Ena bled = False
frm.AllowAdditi ons = False
frm.DataEntry = False

Exit_cmdSave_Cl ick:
Exit Function

Err_cmdSave_Cli ck:
Call LogError(Err.Nu mber, Err.Description ,
"cmdSave_Click( )", "modFormNavigat ion")
Resume Exit_cmdSave_Cl ick
End Function

Apr 28 '06 #3
Ken Mylar wrote:
Thanks for your help! I'm not sure how to go about storing the ID when
I save the record.
Go to the top of the code. Under your Option statemets (I assume you
have at least OptionExplicit) , enter something like
Dim lngStoreID As Long

In the BeforeUpdate or AfterUpdate event of the form, store the ID. Ex:
lngStoreID = Me.ID

See code comments below. BTW, it assumes your id is numeric long.

I have a bunch of forms that all the same exact buttons, so I created all my code as a Public Function, so I didn't
have to keep duplicating all the same code. The Save function is shown
below, I hope this can work on a global level because it sounds like
exactly what I need. If not, I may need to take the Save function down
to form level.

Thanks,
Ken
*************** *************** *************** *************** *************** ****
Public Function cmdSave_Click(f rm As Form)
On Error GoTo Err_cmdSave_Cli ck

Dim ctl As Control

For Each ctl In frm.Controls
If ctl.Tag = "Unlockable " Then
ctl.Enabled = False
ElseIf ctl.Tag = "AlwaysLock ed" Then
ctl.Enabled = False
End If
Next ctl

DoCmd.RunComman d acCmdSaveRecord

frm.cmdFirst.En abled = True
frm.cmdPrevious .Enabled = True
frm.cmdNext.Ena bled = True
frm.cmdLast.Ena bled = True
frm.cmdClose.En abled = True
frm.cmdEdit.Ena bled = True
frm.cmdNew.Enab led = True
frm.cmdDelete.E nabled = True
frm.btnUndo.Ena bled = False
frm!cmdEdit.Set Focus
frm.cmdSave.Ena bled = False
frm.AllowAdditi ons = False
frm.DataEntry = False
It appears that when you set dataentry to false, it "requery's" the
form. In that case, put the code
Dim rst As Recordset
set rst = Me.RecordsetClo ne
rst.Findfirst "ID = " & lngStoredID
Me.bookmark = rst.Bookmark
rst.close
set rst = Nothing
here.

Exit_cmdSave_Cl ick:
Exit Function

Err_cmdSave_Cli ck:
Call LogError(Err.Nu mber, Err.Description ,
"cmdSave_Click( )", "modFormNavigat ion")
Resume Exit_cmdSave_Cl ick
End Function

Apr 28 '06 #4
"Ken Mylar" <km****@elch.or g> wrote in news:1146241989 .849337.156600
@i39g2000cwa.go oglegroups.com:
I have a dilema here that I'm hoping some one can help me out with.

On my forms I have some basic New, Edit, Save, Delete, Undo buttons on
them.


When you get this perfected are you going to sell it so the rest of us
don't have to use the trusted, safe, convenient, quick Access way that MS
spent millions to create and maintain, and that we paid for when we bought
Access?

--
Lyle Fairfield
Apr 28 '06 #5
They are the same buttons that the wizard dropped in place. With the
same code behind them except for some GUI changes.

I don't think my Access made Undo button should always look like it can
be pressed as defaulted. And that I don't like my edit button to be
enabled when I'm already editing or my Save button to look enabled when
I haven't changed anything or my New button to be enabled when I'm
editing or entering a new record. I also don't want my users to be able
to leave the current record while editing or entering a record.

All the above wasn't too difficult to take care of and I had one thing
that bugged me, which was why I posted the message.

Ken

Lyle Fairfield wrote:
When you get this perfected are you going to sell it so the rest of us
don't have to use the trusted, safe, convenient, quick Access way that MS
spent millions to create and maintain, and that we paid for when we bought
Access?

--
Lyle Fairfield


Apr 28 '06 #6
That did the trick, Thanks.

Ken

Apr 28 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3551
by: Robert Neville | last post by:
I am having some trouble with some old code revolving around custom form navigation buttons. My main form has a sub-form with these custom navigation buttons. In other words, the code should be modular and work across forms and sub-forms. My previous code was taken from the Access Expert Solutions 97 (Leszynski) many years ago. As my database became more complex with multiple sub-forms and intricate combo boxes, the code faltered. Some...
1
1702
by: Sky Sigal | last post by:
(PS: Cross post from microsoft.pulic.dotnet.framework.aspnet.webcontrols) I've been looking lately for a way to keep the Properties panel for Controls 'clean'... My goal is to keep similar public properties of a custom Control neatly tied together -- rather than all over the IDE. One such set of values that will rarely be changed, so should have little priority in the IDE Properties panel, and therefore a good candidate for
0
972
by: Vi | last post by:
Hi, I have a form that lists orders from a database. All orders have the same format. Each order has an order header that consists of: - a few labels with orders numbers and some general details about the orders; - a few buttons for Edit, Delete, Save order; and an order body that consists of: - a table listing more granular details about the order (3-5 rows). I’m not sure how to create this page, because there’re might be one ore...
5
2647
by: | last post by:
Hi all, Has anyone been able to write some custom javascript on the onclick event of submit button to do certain things like disable submit button, only submit form once etc. This was a breeze in 1.1 since I could edit the .js file. Now in 2.0 I can no longer do this. Also, my code would have to be called after all client-side validation was done and was successful. Any ideas? TIA!
3
2047
by: Woody Splawn | last post by:
We have a client server application where we would like to not show Save and Cancel buttons on a winform until the user has actually entered something into a textbox or combobox etc., and there is something to actually save. This logic is fundamental to the way we would like to do things in general so it is worth our while to get this figured out correctly once and for all. To my mind, what needs to be done is to be able to detect when...
1
2911
by: timnels | last post by:
I have a custom business object that implements INotifyPropertyChanged and IEditableObject. The collection of these objects inherits from BindingList<T>. I created a BindingSource from which a grid (list of objects) and a detail groupbox where bunch of textboxes are bound to them. Problem is I need to detect 2 things: 1. A way to know the current record is dirty (meaning any bound property has changed), so I can enable/disable the...
0
1067
by: LieWait | last post by:
I have a custom business object that implements INotifyPropertyChanged and IEditableObject. The collection of these objects inherits from BindingList<T>. I created a BindingSource from which a grid (list of objects) and a detail groupbox where bunch of textboxes are bound to them. Problem is I need to detect 2 things: 1. A way to know the current record is dirty (meaning any bound property has changed), so I can enable/disable the Save...
2
19491
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I will be writing this article intended for those who are in the same level, or maybe lower, of my technical knowledge. I would be using layman's words, or maybe, my own words as how I understand them, hoping, you will understand it the same way that...
0
2897
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I will be writing this article intended for those who are in the same level, or maybe lower, of my technical knowledge. I would be using layman's words, or maybe, my own words as how I understand them, hoping, you will understand it the same way that...
0
9579
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
9415
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,...
0
10198
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9978
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
9848
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...
1
7392
isladogs
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5293
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...
2
3551
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2810
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.