Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Lock Down Edit on one Form Based on Action from Another

Status
Not open for further replies.

ddevil

Technical User
Feb 14, 2006
49
US
I want to be able to set the allow edits property on a different form when a button is selected on the current form. The code is below and it runs without error, but when I open the form I'm trying to set, the allow edits property is Yes and not No.

Any ideas would be great. Thanks!

Private Sub NotifyAM_Click()
Dim cnn As New ADODB.Connection
Dim rstTo As New ADODB.Recordset
Dim answer As Integer
Dim EmailText As String
Dim ToReceiver, Subject As String
Subject = "ED Updated Project Aging Data"
EmailText = "The Project Aging Information has been updated and ready for your review. Thank you!"

Set cnn = CurrentProject.Connection
rstTo_Open "Select * from Tlkp_Employee where RoleID in (6)", cnn, adOpenDynamic, adLockOptimistic

Do While Not rstTo.EOF

Dim toStr As String


Do While Not rstTo.EOF
toStr = toStr & rstTo("EmployeeEmailAddress") + ";"
rstTo.MoveNext
Loop

'DoCmd.SendObject acSendQuery, "qry_AM_Export_of_Data", acFormatXLS, toStr, , , Subject, EmailText, False
DoCmd.SendObject acSendNoObject, , , toStr, , , Subject, EmailText, False
Loop

'Form_frm_Consultant_Updates.AllowEdits = False


End Sub
 
how about
Code:
forms!frm_Consultant_Updates.AllowEdits = False
 
If I understand you correctly
frm_Consultant_Update is not open

1)so you need the code to open the form first and then set the property.

2)or to make it persistent then have the code open in design view, and hidden. Set the property, save the form, make visible.
 
Now I get an error that says Run-time error '2450': Microsoft Office Access can't find the form 'frm_Consultant_Updates' referred to in a macro expression or Visual Basic code. This is the correct name of the form, I doubled checked.

Any other ideas, help was no help?
 
That is correct the form is not open. I have never done what you are suggesting before, can show me some sample code?
 
Yes you will get that error if the form is not open.

Not sure which solution you want. If you want it open immediately then
1)docmd.openform("frm_Consultant_Updates")
forms("frm_Consultant_Updates").allowedits = false

that opens the form then changes the value.

2) If you are looking to make it permanent. Here is an example of opening form Categories hidden, changing the property, saving it, then closing it.
DoCmd.OpenForm "Categories", acDesign, , , , acHidden
Forms("Categories").AllowEdits = False
DoCmd.Save acForm, "Categories"
DoCmd.Close acForm, "Categories
 
Great exactly what I needed. Thank you!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top