The following synopsis is based on the following criteria:
**********************************************************
1) Since your form is already setup for Data Entry, we will lock the form to that
function only. (No skiming of added records. I don't believe you want users
fooling around with previously saved data!).
2) Provide the schema for switching between Data Entry Only and Viewing All Records.
This provides full access to the administrator.
3) Provide the schema for detection of the radio buttons.
4) Provide the schema for detection of required fields.
Locking The Form In Data Entry. Assume the Data Entry Property is already set to yes.
If not, make it so.
-------------------------------------------------------------------------------------
a) Open the form in design view and open the Properties window. You can always do
this by double-clicking the small black box, just to the left of the ruler. This
always brings up the Form Properties.
b) On the Format tab, set Navigation Buttons to "No". This prevents skiming added
records.
c) On the Other tab, set Cycle to Current Record. This prevents the focus from
spilling over to the previous or next record. Data entry is now locked! Moving to an additional new record will be up to the Submit command button, or any schema of your choice.
Switching between Data Entry Only and Viewing All Records:
----------------------------------------------------------
a) In a module in the module window, add the following code:
Public Function IsOpenFrm(frmName As String) As Boolean
Dim cp As CurrentProject, Frms As Object
Set cp = CurrentProject()
Set Frms = cp.AllForms
If Frms.Item(frmName).IsLoaded Then IsOpenFrm = True
Set Frms = Nothing
Set cp = Nothing
End Function
Public Function TglViewMode()
Dim frm As Form
If IsOpenFrm("YourFormName") Then
Set frm = Forms!YourFormName
If frm.DataEntry Then
frm.DataEntry = False
frm.NavigationButtons = True
Else
frm.DataEntry = True
frm.NavigationButtons = False
End If
Set frm = Nothing
End If
End Function
Note: Fill-in YourFormName as required in the function TglViewMode.
b) In the Macros window, open new. In the Macro Name column, add the following:
^+V
Thats a caret, plus symbol, and capital V. These are the hotkeys (Ctrl+Shift+V)
for toggling between Data Entry & All View. In the Action column select RunCode. In the Function Name on the bottom left, enter TglViewMode(). On the next Action line select StopMacro. Close the macro and name it AutoKeys. Open the form and test the keys! You can of course call the TglViewMode function by any schema you like. Just remember its a toggle.
Detection of the radio buttons
------------------------------
a) The Idea here is to pack a byte with the status of each radio button (each button
represents a bit in the byte), resulting in a count that you can easily step thru and detect Required Fields accordingly. Lets say for the moment we have three radio buttons named RB1, RB2, RB3. The code would go a little like this:
Dim rbStatus as Integer
If RB1 then rbStatus = rbStatus Or 1
If RB2 then rbStatus = rbStatus Or 2
If RB3 then rbStatus = rbStatus Or 4
Now you can increment through all the possible combinations.
b) There's a point Id like to make here. You might want to consider adding a field to your table to contain this byte. You have no way of knowing how the radio buttons
were set in a previously saved record! Saving this byte you could preset the
buttons accordingly!
Detection of required fields
----------------------------
From here I think you have the picture. An If-ElseIf-EndIf statement is used to pick
rbStatus apart, and checks Required Fields accordingly. I would add message prompts for any fields that fail.
Last, is the incorporation of a Submit button. Here the code is run. If required fields
are ok, then you save the current record and move to a new one, else you set the focus
to the first Required Field that fails after the message prompt.