Form field problems

G

Guest

I have a table HYInReg which uses three forms, one for data entry, one for
data edit and one for data delete. I am also using the audit log function by
Alan Browne. By using this function I can create a log of inserts, edits and
deletions. The entry and edit forms work okay however I cannot get the
functionality of the delete form to work correctly.

I have an unbound combo box from which the user selects the record for
deletion. I then have a yes/no check box to confirm the record is the
correct one. If the check box is checked I have additional fields that
require entry.

DeleteDate - bound text box to table HYInReg
DeptReqDel - combo box using a table DeptCode as source
PersonReqDel - bound text box to table HYInReg
ReasonforDel - bound text box to table HYInReg

I then have various command buttons for canceling entry, printing and
returning to switchboard.

My problems are that if I make the form data entry NO I can use the combo
box to select the required record which then populates the fields with
information already in table to ensure it is the correct records however; the
fields that then require additional data entry will not use their default
properties eg. current date and user ID (using fOSUserName). If I set form
data entry to YES the current date and user details appear but the combo box
will not selete the records.

If all the fields are entered the additional information should then be
stored in the audit log table; but the record will be deleted from HYInReg.

Can anybody please please please explain to me where I am going wrong; I
have tried all sorts of combinations but to no avail. Your responses are
greatly appreciated I could have got this far without this service.
 
G

Guest

Why do you feel you need 3 forms to work on one table? This means every time
there is a change, you have to do the work 3 times. Why not use one form?
You can add, modify, and delete records all from the same form.
 
G

Guest

Thank you for this suggestion however; the edit & delete forms contain
additional fields over the data entry form, I am unsure of how to get access
to differeniate between them so that if I use VB code to ensure that field
'reason for edit' for example has not been completed then it will only give
the error message in 'edit mode' not entry or delete. I would appreciate it
if you could give me some guidance on this.
 
G

Guest

It is interesting the edit and delete have additional fields. If you don't
put them in during data entry, how do they get there? This is not
unreasonable. In many apps, fields in a table may be filled in or modified
by other processes.

There are a number of ways you can approach this, depending on how you call
your forms and how you have the form's behaviour coded.

If the Edit and Delete versions have the same number of fields, it would be
pretty easy to implement. You could use the Current Event of the form to
hide the controls you don't want in the data entry mode:

Dim blnShowControls As Booleam

blnShowControls = Not Me.NewRecord

Me.txtSomeControl.Visible = blnShowControls
Me.txtAnotherControl.Visible = blnShowControls
'Add one line for each control you want to hide for data entry.

If there are difference in the Edit, Delete forms, you can use the OpenArgs
argument of the OpenForm method to tell the form what to do. Look up
OpenArgs in VBA Help. Instead of the 3 forms you use now, open the 1 form,
with a different value in the OpenArgs argument.

Then in the Load event of the form make the controls visible or invisible
depending on the value passed:

Select Case Me.OpenARgs
Case Is = "new"
'Show or Hide contorls as needed
'Position on a new record
Docmd.GotoRecord acNewRec
Case Is = "edit"
Case Is = "delete"
End Select
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top