Read only form, still want to be able to use cbosearch box

G

Guest

Good Day all,

I use the following code from a command button to open my form for read
only so that orders are not deleted or modified...

DoCmd.OpenForm FormName:="frmOrders", DataMode:=acFormReadOnly ',
WindowMode:=acDialog

However, I have code below that I use to do a lookup / search within my form
records. How can I do this with the form being opened in ReadOnly? Would I
have to manually lock all records except for this record upon opening the
form?

Private Sub Combo158_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[ordnum] = '" & Me![Combo158] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub

thanks,

Brook
 
M

Marshall Barton

Brook said:
I use the following code from a command button to open my form for read
only so that orders are not deleted or modified...

DoCmd.OpenForm FormName:="frmOrders", DataMode:=acFormReadOnly ',
WindowMode:=acDialog

However, I have code below that I use to do a lookup / search within my form
records. How can I do this with the form being opened in ReadOnly? Would I
have to manually lock all records except for this record upon opening the
form?

Private Sub Combo158_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[ordnum] = '" & Me![Combo158] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub


The find record procedure should not care if the data is
read only or not. What problem are you having with it?
 
G

Guest

Marshall,

the problem I have having is that my lookup doens't work, it will show
the records that I am trying to go to, but won't let me choose a record for
the form to "goto"?

Hope this is clear?

Brook

Marshall Barton said:
Brook said:
I use the following code from a command button to open my form for read
only so that orders are not deleted or modified...

DoCmd.OpenForm FormName:="frmOrders", DataMode:=acFormReadOnly ',
WindowMode:=acDialog

However, I have code below that I use to do a lookup / search within my form
records. How can I do this with the form being opened in ReadOnly? Would I
have to manually lock all records except for this record upon opening the
form?

Private Sub Combo158_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[ordnum] = '" & Me![Combo158] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub


The find record procedure should not care if the data is
read only or not. What problem are you having with it?
 
R

Rick Brandt

Brook said:
Marshall,

the problem I have having is that my lookup doens't work, it will
show the records that I am trying to go to, but won't let me choose a
record for the form to "goto"?

You are apparently making the form read only by using AllowEdits = False. That
will also make unbound controls like your ComboBox read only. Instead you could
make the form read only by setting the RecordSourceType to Snapshot. That will
not affect your ComboBox.
 
M

Marshall Barton

Ahh, I misunderstood. It's the form that's read only, just
as you said. Somehow I was thinking it was the form's
recordset that was read only.

Because the form is read only, you can not enter the find
critera, so you can not open the form in read only mode to
allow the form to modfiy at least that one value. To
prevent changes to the other control values, set all the
bound control's Locked property to Yes.
--
Marsh
MVP [MS Access]

the problem I have having is that my lookup doens't work, it will show
the records that I am trying to go to, but won't let me choose a record for
the form to "goto"?

Brook said:
I use the following code from a command button to open my form for read
only so that orders are not deleted or modified...

DoCmd.OpenForm FormName:="frmOrders", DataMode:=acFormReadOnly ',
WindowMode:=acDialog

However, I have code below that I use to do a lookup / search within my form
records. How can I do this with the form being opened in ReadOnly? Would I
have to manually lock all records except for this record upon opening the
form?

Private Sub Combo158_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[ordnum] = '" & Me![Combo158] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub
Marshall Barton said:
The find record procedure should not care if the data is
read only or not. What problem are you having with it?
 
G

Guest

Thanks Rick,

would I modify this section of code:

DoCmd.OpenForm FormName:="frmOrders", DataMode:=acFormReadOnly ',
WindowMode:=acDialog

or do I need to modify each field within my form?

Brook
 
T

tina

try

DoCmd.OpenForm FormName:="frmOrders", WindowMode:=acDialog
Forms!frmOrders.RecordsetType = 2

"2" is the code for Snapshot (refer to Rick's post elsewhere in this
thread).

hth
 
G

Guest

Tina,

Thanks for the post, however when I add your the modified code you
provided, I get a debugging error on the Forms!frmorders.recordsetype = 2
portion of the code...

Do I need some type of continuation after the first line of code? After the
acDialog ?

Brook
 
T

tina

oh yeah, duh - sorry about that. since you're opening the form as Dialog
window mode, the rest of the code should be suspended until the form is
closed again. try this instead:

add the following code to frmOrders' Load event, as

Private Sub Form_Load()

If Me.OpenArgs = "ReadOnly" Then
Me.RecordsetType = 2
End If

End Sub

then, in the other form, change the OpenForm code to

DoCmd.OpenForm FormName:="frmOrders", WindowMode:=acDialog,
OpenArgs:="ReadOnly"

the above all on one line, of course.

hth
 
G

Guest

Perfect!!!

Thanks for everything Tina... and thanks everyone else for your suggestions!

Brook
 

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