Add/Edit new record only continuous form (1 Viewer)

foshizzle

Registered User.
Local time
Today, 14:31
Joined
Nov 27, 2013
Messages
277
I have a continuous form with unbound controls. These controls write new records into a table using rec.addnew

If possible, I would like for the user to only be able to add/edit the new record only and not to edit the continuous form below. When I turn off edits on the form, I only get the new record to show. I found some pages that reference using code like .allowAdditons, .allowEdits and .allowDeletions but unsure of how to implement them since I have more than one control the user is entering data into. I also found another site that says to use a control to determine if the record is writable to: if it helps, I do have a control that is set to =Date() on the default value.

Thanks
 

CJ_London

Super Moderator
Staff member
Local time
Today, 19:31
Joined
Feb 19, 2013
Messages
16,609
can you describe in different words what you have - perhaps post a picture.

Your statements
I have a continuous form with unbound controls
and
and not to edit the continuous form below
don't make sense
 

foshizzle

Registered User.
Local time
Today, 14:31
Joined
Nov 27, 2013
Messages
277
hi

I attached a screenshot for your review. The top of the form shows controls where the user will enter data, which then appear in the below part of the continuous form. ( It is not a split form). Also, the top controls used for data entry are unbound if it makes a difference.

Currently, I am able to both add records using these controls as well as edit the previous entries found below. If possible, i do not want the user to be able to edit the below entries, and only be able to add records via the top controls.

Hope that makes sense.
 

Attachments

  • Capture.PNG
    Capture.PNG
    39.3 KB · Views: 494

jdraw

Super Moderator
Staff member
Local time
Today, 14:31
Joined
Jan 23, 2006
Messages
15,379
I made a quick and dirty mock up of your form.
The top section has unbound controls Name,Note and a button. OnClick of button saves the unbound data to a table; it inserts Now() (current date and time) then resets the unbound fields. It then requeries the subform that is a snapshot that has no edits, no additions, no deletions.



Code:
Private Sub Command10_Click()
On Error GoTo Err_Command10_Click
Dim msql As String
msql = "INSERT INTO MyReadOnlyTable(myTimestamp,Person,mynote) Values( '" & Now() & "','" & Combo6 & "','" & Text8 & "')"
CurrentDb.Execute msql, dbFailOnError

  Me.Text4 = ""
  Me.Text8 = ""
  Me.sfrmReadOnly.Requery
     
Exit_Command10_Click:
    Exit Sub

Err_Command10_Click:
    MsgBox Err.Description
    Resume Exit_Command10_Click
    
End Sub

Good luck.
 

Attachments

  • Created and saved2 records.jpg
    Created and saved2 records.jpg
    53 KB · Views: 579
  • WithThirdRecord.jpg
    WithThirdRecord.jpg
    52.3 KB · Views: 268

foshizzle

Registered User.
Local time
Today, 14:31
Joined
Nov 27, 2013
Messages
277
Hmm.. To me, it sounds like it's the same setup.
I attached the form and here is what I use for my save button control
Code:
Dim DB As Database
Dim rec As Recordset

Set DB = CurrentDb
Set rec = DB.OpenRecordset("Select * from tblBlotter")

'test required fields
If IsNull(Me.txtEntryDate) _
        Or IsNull(Me.txtEntryTime) _
        Or IsNull(Me.cboBadge.Value) Then
    
    MsgBox "Please fill in all required fields."
Else

'add records to able
rec.AddNew
rec("EntryDate") = Me.txtEntryDate
rec("EntryTime") = Me.txtEntryTime
rec("BadgeNum") = Me.cboBadge.Value
rec("Location") = Me.cboLocation.Value
rec("Response") = Me.txtResponse
rec("OType") = Me.opOType.Value

rec.Update

MsgBox "Record saved."

'Requery
Me.Requery

' Clear All Controls
   
    Me.txtEntryTime = Now()
    Me.EntryDate = Date
    Me.cboBadge.Value = Null
    Me.cboLocation.Value = Null
    Me.opOType = Null
    Me.txtResponse = ""

End If
 

Attachments

  • Database1.accdb
    896 KB · Views: 157

jdraw

Super Moderator
Staff member
Local time
Today, 14:31
Joined
Jan 23, 2006
Messages
15,379
Ok What exactly do you want.
My crude mockup has unbound Controls and a button at the top. Fill in the Controls, click the button and you save/ADD the record; then clear the controls; and requery the form. No editing etc.

The bottom section shows the records --READ ONLY -- no edits in the underlying table. No additions, no deletions.

I was responding to this which I thought was the requirement.
If possible, i do not want the user to be able to edit the below entries, and only be able to add records via the top controls.
 

foshizzle

Registered User.
Local time
Today, 14:31
Joined
Nov 27, 2013
Messages
277
You're right, that's what I want. I guess I'm asking which part makes the underlying table read-only. Like you, I have the save button set to insert the records in the table, just using a different command.

Perhaps It's something on my form itself thats causing me to be able to edit the bottom half? I cant set it to no edits, because then It won't let me write in the top, or change the combobox entries.
 

jdraw

Super Moderator
Staff member
Local time
Today, 14:31
Joined
Jan 23, 2006
Messages
15,379
I don't see where your code from your post#5 is located.
I thought you were using the NavigationButton141
and a Click. But there's no event for that button.

Where do you do the Add Record. My test records are not adding and there is No Message given -- so I am not going through the code you showed in post #5.

The other thiing I don't understand in your set up, is how am I suppose to go through the records at the bottom -- if I only wanted to scan through them to get some idea of the content of Notes?

I can modify the bottom so it can't edit/delete, but I'm not able to add records with the database as it is. It definitely is not going through the code you showed.
 

foshizzle

Registered User.
Local time
Today, 14:31
Joined
Nov 27, 2013
Messages
277
I see, sorry.

Navigation button just opens the form frm_BLT_Update.

The code in #5 is located in the on click event of frm_BLT_Update on the control called btnSave, event On Click which adds the record to tblBlotter.

Currently all I have to do is click in one of the controls at the bottom of frm_BLT_Update and it lets me edit them. There is a scrollbar if thats what you are referring to
 

CJ_London

Super Moderator
Staff member
Local time
Today, 19:31
Joined
Feb 19, 2013
Messages
16,609
not sure if you are missing the obvious - you set the subform form to no edits
 

foshizzle

Registered User.
Local time
Today, 14:31
Joined
Nov 27, 2013
Messages
277
Currently its set to Allow edits. This subform is all one continous form (no subform). The navigationform is main, yes. Thats what Im trying to say, if I set the subform itself to no edits, then I cant set the combobox and cant type in the other blank unbound controls.
Any other ideas? It still could be I miss obvious things - Ive only really been using Access for 6 months or so
 

jdraw

Super Moderator
Staff member
Local time
Today, 14:31
Joined
Jan 23, 2006
Messages
15,379
Yes CJ, that's how I set up my original test.

helmerr,
That is what I did. Given a form and a subform.
The form uses unbound controls. You select the data you want from your drop downs; fill in the text/memo data; then click a button.
That takes the values from your dropdowns; adds Now for the Date and Time. You Insert a record into your blotter table; then reset your control values. Then requery the subform.

On the bottom you have a subform. The recordsource is tblBlotter. You set allow edits to No,allow additions to no; allow deletes to no; allow edits to No.

Good luck.
 
Last edited:

CJ_London

Super Moderator
Staff member
Local time
Today, 19:31
Joined
Feb 19, 2013
Messages
16,609
I know - it's Helmerr who is missing the point.
 

jdraw

Super Moderator
Staff member
Local time
Today, 14:31
Joined
Jan 23, 2006
Messages
15,379
I know - it's Helmerr who is missing the point.

Yes I thought my post was clear - 2 messages.

1 to CJ saying that's what I did.
2nd to helmerr enumerating the steps.

I have since edited the post to make the 2 messages more distinct.

jack
 

Users who are viewing this thread

Top Bottom