acReadOnly

stephaniechongg

Registered User.
Local time
Today, 21:29
Joined
Feb 5, 2016
Messages
15
I have a problem where i have a search bar in the header of a form and in the previous form i set this coding

Code:
DoCmd.OpenForm "formname with the search bar", acNormal, , , acFormReadOnly

I want to be able to fill in the search bar but also be able to view the form in a readonly view

is there any way to go around this??

the foding for my search box is as follows
Code:
Private Sub cmdSearch_Click()
If IsNull(txtSearch) = False Then
txtSearch = Me.txtSearch.Value
Task = "SELECT * FROM Product_Steph WHERE ((ProductName Like ""*" & txtSearch & "*"") OR (ProductID Like ""*" & txtSearch & "*"") OR (ProductType Like ""*" & txtSearch & "*"") OR (ProductColour Like ""*" & txtSearch & "*""))"
Me.RecordSource = Task
    If Me.RecordsetClone.RecordCount = 0 Then
MsgBox "No record found", vbOKOnly + vbInformation, "Sorry"
End If
Else
   MsgBox "Please enter a value", vbOKOnly + vbInformation, "Sorry"
End If
End Sub
 
i think you need to pass an OpenArgs, ie, "Locked", on opening your form.
on the load event of the main form test the value of Openargs if it is passed.
if it is recurse through each control on your form, setting its locked property to true, except the search bar (is it a subform?).
 
the search bar is embedded into the form header!!!
 
the search bar is embedded into the form header!!!

is it just an ordinary textbox then?
 
yes it is only a textbox!!! then the search command is tiered to the search button next to it!

Do i need to change the text box to something else?
 
no, its fine.
like i said you need to recursed through each control and set its lock property to true, except your search textbox and search button.

on the two controls i mentioned, put a Tag on them (Property sheet->Others->Tag) like "NotLocked"

then on the Load Event of your form:
Code:
Private Sub Form_Load()
    Dim c As Access.Control
    For Each c In Me.Controls
        If TypeOf c Is Access.TextBox Or _
            TypeOf c Is Access.ComboBox Or _
            TypeOf c Is Access.SubForm Then
            If c.Tag & "" = "" Then
                c.Locked = True
            End If
        End If
    Next c
End Sub
 

Users who are viewing this thread

Back
Top Bottom