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

Form Question - How to Avoid Too Many!

I have several databases where I have one form to add a new record and one form
to edit an existing record. I use unbound forms and class modules most of the
time.

What I would like to do is have one form that handles both adding a new record
to the database and editing the same type of record. The form would be altered
in the load event to change whatever needs to be changed to show the form
in an "Add" mode vs. and "Edit" mode (I guess???).

Does anyone have any ideas/experience on this? I'm sure in an truly OOP
environment this is childs play/standard operating procedure. Please let me
know what you think.

Johnny
Nov 13 '05 #1
11 1654
"Johnny M" <jm*******@gmail.com> wrote in message
news:55**************************@posting.google.c om...
I have several databases where I have one form to add a new record and one
form
to edit an existing record. I use unbound forms and class modules most of
the
time.

What I would like to do is have one form that handles both adding a new
record
to the database and editing the same type of record. The form would be
altered
in the load event to change whatever needs to be changed to show the form
in an "Add" mode vs. and "Edit" mode (I guess???).

Does anyone have any ideas/experience on this? I'm sure in an truly OOP
environment this is childs play/standard operating procedure. Please let
me
know what you think.

When you open the form, use the DataMode argument to open in Add or Edit
mode, depending on whether you want to add a new record or edit an existing
one. If you're editing an existing record, pass the PK value of the record
in the OpenArgs argument and have your editing form filter the underlying
data source to find this record.


Nov 13 '05 #2
Johnny M wrote:
I have several databases where I have one form to add a new record and one form
to edit an existing record. I use unbound forms and class modules most of the
time.


Why do you use *unbound* forms when they are supposed to operate upon
data? Bound forms do these jobs quite well, and they're built in.

This is not (merely) a criticising statement, there are times I don't
like the way Access handles various events so I'd like to see your chain
of thought.
Nov 13 '05 #3
> When you open the form, use the DataMode argument to open in Add or Edit
mode, depending on whether you want to add a new record or edit an existing
one. If you're editing an existing record, pass the PK value of the record
in the OpenArgs argument and have your editing form filter the underlying
data source to find this record.


The forms are unbound, so the ADD/EDIT mode is irrelevant, right? Also, I
avoid openargs. I use classes stored in global variables to pass info between
forms.

I'm really looking for a way to mimic inheritance. So, for instance, if I have
a class Document, three derived classes, IDR, NPA, and Claim. I would like
a single Document form, that is changed appropriately based on what Document
I'm actually working with. In VBA, I just have the three class modules IDR,
NPA, and Claim (no abstract class Document, of course.) I just want to know
if anyone has any technique to do this with a form so I don't have to maintain
a bunch of forms that look nearly identical.
Nov 13 '05 #4
Most of my forms are set up like so:

A listBox at the bottom of the form contains a list of all records. Next to
the listBox are two buttons, Edit and New. The New button adds a new
record; the Edit button Finds the needed record and makes it the current
record.

The form is originally opened with all controls except these disabled; only
by selecting Edit or New do the textBoxes and comboBoxes for entereing data
become enabled. Save and Cancel buttons return control to the listBox and
disable the other controls after saving/cancelling.

When a form is loaded, or at some point prior, data from the BE table is
copied to an identical FE table, which is used as the recordsource for the
FE bound form. On Save, the new/edited record is copied to the BE table. I
gain what is to me the considerable benefit of using bound forms, without
the drawbacks of using linked tables.
Darryl Kerkeslager
"Johnny M" <jm*******@gmail.com> wrote:
I have several databases where I have one form to add a new record and one form to edit an existing record. I use unbound forms and class modules most of the time.

What I would like to do is have one form that handles both adding a new record to the database and editing the same type of record. The form would be altered in the load event to change whatever needs to be changed to show the form
in an "Add" mode vs. and "Edit" mode (I guess???).

Nov 13 '05 #5
Johnny M wrote:
I have several databases where I have one form to add a new record and one form
to edit an existing record. I use unbound forms and class modules most of the
time.

What I would like to do is have one form that handles both adding a new record
to the database and editing the same type of record. The form would be altered
in the load event to change whatever needs to be changed to show the form
in an "Add" mode vs. and "Edit" mode (I guess???).

Does anyone have any ideas/experience on this? I'm sure in an truly OOP
environment this is childs play/standard operating procedure. Please let me
know what you think.


How would you like to handle tables with (vastly) different amounts of
fields? Controls can be created (and deleted) in design view only.

I get the impression I am interested in your project. Do you care for an
email discussion?
Nov 13 '05 #6
"Johnny M" <jm*******@gmail.com> wrote in message
news:55**************************@posting.google.c om...
When you open the form, use the DataMode argument to open in Add or Edit
mode, depending on whether you want to add a new record or edit an
existing
one. If you're editing an existing record, pass the PK value of the
record
in the OpenArgs argument and have your editing form filter the underlying
data source to find this record.


The forms are unbound, so the ADD/EDIT mode is irrelevant, right? Also, I
avoid openargs. I use classes stored in global variables to pass info
between
forms.

I'm really looking for a way to mimic inheritance. So, for instance, if I
have
a class Document, three derived classes, IDR, NPA, and Claim. I would
like
a single Document form, that is changed appropriately based on what
Document
I'm actually working with. In VBA, I just have the three class modules
IDR,
NPA, and Claim (no abstract class Document, of course.) I just want to
know
if anyone has any technique to do this with a form so I don't have to
maintain
a bunch of forms that look nearly identical.


I would suggest changing to use bound forms - otherwise you're creating a
lot of extra work for yourself with input validation. Plus you lose the
advantage of many of the form's data-driven events. If you don't want to
maintain a connection to the underlying data source you can create your own
recordset using ADO, disconnect it from the underlying source and then bind
it to the form. When the user presses OK, you just walk through the
recordset and update or add the record in code as appropriate. I know this
technique works for SQL Server data - I think it also works for Jet in
Access XP but you'll need to check that one.

Nov 13 '05 #7
rkc

"Johnny M" <jm*******@gmail.com> wrote in message
news:55**************************@posting.google.c om...
When you open the form, use the DataMode argument to open in Add or Edit
mode, depending on whether you want to add a new record or edit an existing one. If you're editing an existing record, pass the PK value of the record in the OpenArgs argument and have your editing form filter the underlying data source to find this record.
The forms are unbound, so the ADD/EDIT mode is irrelevant, right? Also, I
avoid openargs. I use classes stored in global variables to pass info

between forms.

I'm really looking for a way to mimic inheritance. So, for instance, if I have a class Document, three derived classes, IDR, NPA, and Claim. I would like a single Document form, that is changed appropriately based on what Document I'm actually working with. In VBA, I just have the three class modules IDR, NPA, and Claim (no abstract class Document, of course.) I just want to know if anyone has any technique to do this with a form so I don't have to maintain a bunch of forms that look nearly identical.


You mimic inheritance in VBA using containment and delegation. Two concepts
that you should be familiar with if you're interested in using OOP with
Access.

The only practical way of using a single form for multiple operations is to
create one that contains all the controls neccesary for each. Make all
common controls visible and show any additional ones when needed.

Instead of passing a document object to a form your document object would
contain an instance of the form. The appearance of the form and the showing
of additional controls is handled when the document object is instantiated.
Obviously your Document object would have complete knowledge of the form's
controls and would have to handle some of the events.

Personally I'd take another look at using multiple bound forms.


Nov 13 '05 #8
jm*******@gmail.com (Johnny M) wrote in
news:55**************************@posting.google.c om:
I have several databases where I have one form to add a new
record and one form to edit an existing record. I use unbound
forms and class modules most of the time.

What I would like to do is have one form that handles both
adding a new record to the database and editing the same type
of record. The form would be altered in the load event to
change whatever needs to be changed to show the form in an
"Add" mode vs. and "Edit" mode (I guess???).

Does anyone have any ideas/experience on this? I'm sure in an
truly OOP environment this is childs play/standard operating
procedure. Please let me know what you think.

Johnny

With a bound form, it's as easy as opening the form with
different arguments,
DoCmd.OpenForm stDocName,,,,acFormAdd
DoCmd.OpenForm stDocName,,,,acFormEdit

--
Bob Quintal

PA is y I've altered my email address.
Nov 13 '05 #9
> I would suggest changing to use bound forms - otherwise you're creating a
lot of extra work for yourself with input validation.


Do you use table level validation rules? Where does you validation occur when
using bound forms?
Nov 13 '05 #10
"Johnny M" <jm*******@gmail.com> wrote in message
news:55**************************@posting.google.c om...
I would suggest changing to use bound forms - otherwise you're creating a
lot of extra work for yourself with input validation.


Do you use table level validation rules? Where does you validation occur
when
using bound forms?


It depends. The form can check for incorrect data type for example, but it
has no way to check for constraints such as check or foreign key violations.
You do this in your return code. That's another good reason for using
disconnected recordsets and handling the update youreslf - so you can
intercept constraint violations and return a nice message to the user
instead of the cryptic one that the database supplies.
Nov 13 '05 #11
> I get the impression I am interested in your project. Do you care for an
email discussion?


Tried to email at above address and it failed. Please email me with
correct address (jm*******@gmail.com)
Nov 13 '05 #12

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

Similar topics

72
by: Stephen Poley | last post by:
I have quite often (as have probably many of you) come across HTML forms with irritating bits of Javascript attached. The last straw on this particular camel's back was a large form I was asked to...
17
by: KS | last post by:
I got 2 inputs in a form where I want check if start > end. Seems like it just compare the first number when I got this code in javascript "if(document.all.start > document.all.end)" How do i...
8
by: Sergio Otoya | last post by:
Hi all, I need to add an input hidden field to an existing form (post). I have tried a couple things like adding the '<INPUT type=hidden name=idSelectedURL value=http://server/documents>' to...
6
by: allyn44 | last post by:
HI--what I am trying to do is 2 things: 1. Open a form in either data entry mode or edit mode depending on what task the user is performing 2. Cancel events tied to fields on the form if I am in...
16
by: TD | last post by:
This is the code under a command button - Dim ctl As Control For Each ctl In Me.Controls If ctl.BackColor <> RGB(255, 255, 255) Then ctl.BackColor = RGB(255, 255, 255) End If Next ctl
17
by: Timothy.Rybak | last post by:
Hello all, This is my first attempt at an application, so kid gloves are appreciated. I need to make a very simple form that only has a few elements. One is TraceCode - a text field that is...
5
by: superjacent | last post by:
Hope someone can help. I have a saved parent form containing an unbound sub-form. I set the SourceObject (form) after the Parent Form opens/loads. The sub-form (datasheet view) basically...
17
by: radio1 | last post by:
Configuration: Access 2002 and SQL Server 2000 using a .ADP Project. I would VERY MUCH appreciate anyone's input into this problem I'm having. I have a form in Access that does not permit...
224
by: Jon Slaughter | last post by:
Sorry for all the cross posting but I'm interesting in getting a serious discussion about how usenet has become lately. Many people are moving away from usenet because of all the spam and cooks...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.