?
Solved

ms access autoexec

Posted on 2014-10-24
9
Medium Priority
?
504 Views
Last Modified: 2014-10-24
Howdy,
I have a MS Access database. The Office Manager, where the DB is hosted, wants the ability to hide/unide a control on a subform (frmCreditCards). Normally, not a difficult task! However, because the DB is split, I have adopted a script that, when an end user clicks the DB shortcut icon on their respective workstation, the user interface is copied to a local folder on that workstation and the DB opens. This allows me to easily make interface changes and upload the new interface to the server. All the user needs to do is close/open the DB and the changes are there, without interrupting DB activity. This seemed easier than using one of the available split database interface tools that constantly checks and updates the interface...

Herein lies the problem. I have a command button on the "Admin" form (frmAdmin) that, when pressed, toggles a control on a subform (frmCreditCards) of the main form (frmMembers). Here's the code:

Private Sub btnLockDeclined_Click()
On Error GoTo Err_btnLockDeclined_Click

   'toggle the control
    If Forms!frmMembers!frmCreditCards.Form.cbDeclined.Visible = False Then
        Forms!frmMembers!frmCreditCards.Form.cbDeclined.Visible = True
    Else
        Forms!frmMembers!frmCreditCards.Form.cbDeclined.Visible = False
    End If
   
Exit_btnLockDeclined_Click:
    Exit Sub

Err_btnLockDeclined_Click:
    MsgBox "The Main Member's form must be opened to perform this action..."
    Resume Exit_btnLockDeclined_Click
End Sub

This works fine, but because the interface is local on each workstation, the changes only show on the Manager's interface! I have experimented with the AutoExec macro, trying to set the state of the control (cbDeclined) on startup, but this was not successful. The macro cant find the control...

I was thinking of writing the Manager's selection (cbDeclined.visible = true/false) to a text file. Then, when the DB opens, it opens and reads the file, sets the control accordingly, then copies that interface to the end user's workstation...This way would be cool, because the DB control would remain in the last set state...

How exactly to do this? Could spend hours experimenting, but don't have hours! Any suggestions, with code examples are appreciated! Also, can I hide the control without having the Main Member's form open?
0
Comment
Question by:waverobber
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 37

Expert Comment

by:Neil Russell
ID: 40402824
Create a config Table in your back end, have a record that stores the "State" of that button. When your app opens, it reads the data from table and sets app state.
0
 

Author Comment

by:waverobber
ID: 40402905
Sounds pretty good...I'll give it a go and get back at ya! Thanks Neilsr...
0
 
LVL 37

Expert Comment

by:Neil Russell
ID: 40402908
Pleasure. If you need any further advice on it, feel free to ask.
0
Does Your Cloud Backup Use Blockchain Technology?

Blockchain technology has already revolutionized finance thanks to Bitcoin. Now it's disrupting other areas, including the realm of data protection. Learn how blockchain is now being used to authenticate backup files and keep them safe from hackers.

 

Author Comment

by:waverobber
ID: 40403128
Howdy Neil...
I tried every conceivable combination trying to read a single record from the new table (tblConfig), to fill a test variable...Every time, I get the Err_Description.

Private Sub btnLockDeclined_Click()
On Error GoTo Err_btnLockDeclined_Click

    Dim dbs As DAO.Database
    Dim rsTable As DAO.Recordset

    Set dbs = CurrentDb
    Set rsTable = dbs.OpenRecordset("tblConfig", dbOpenTable)
    Dim myVar As Boolean
    myVar = rsTable![DeclinedState]         'exception is thrown here...tried all combinations of syntax
   
    set rstTable = nothing

Exit_btnLockDeclined_Click:
    Exit Sub

Err_btnLockDeclined_Click:
    MsgBox "The Main Member's form must be opened to perform this action..."
    Resume Exit_btnLockDeclined_Click
End Sub
0
 
LVL 37

Accepted Solution

by:
Neil Russell earned 2000 total points
ID: 40403169
use something like this.

tblConfig definition:

Two fields,  ConfigName Text, ConfigValue Text

Now you can do.....

Dim rsTable As DAO.Recordset

Set rsTable = Application.CurrentDb.OpenRecordset("tblConfig", dbOpenDynaset)
rsTable.FindFirst "ConfigName=""DeclinedState"""
If rsTable.NoMatch = False Then
    MyVar = rsTable.Fields!ConfigValue
End If

And MyVar will be set to the value of the field ConfigValue for the row in tblConfig that has a ConfigName of DeclinedState

Hope that makes sense?
0
 

Author Comment

by:waverobber
ID: 40403223
Okay thanks Neil...That works. My table def was slightly "skewed!" Last question: Is there a way to set the control (cbDeclined) in the subform (frmCreditCards) without having the form open? I'd like the Manager to be able to set the visible = true/false property in either situation...I'm using:

    If Forms!frmMembers!frmCreditCards.Form.cbDeclined.Visible = False Then
        Forms!frmMembers!frmCreditCards.Form.cbDeclined.Visible = True
    Else
        Forms!frmMembers!frmCreditCards.Form.cbDeclined.Visible = False
    End If

which works only if parent form (frmMembers) and subform are opened...
0
 

Author Closing Comment

by:waverobber
ID: 40403225
I forgot the KISS rule...Keep it simple stupid! Thanks dude. Now I'm thinking I can use the tblConfig for many user defined defaults!
0
 
LVL 37

Expert Comment

by:Neil Russell
ID: 40403243
Yeah, its a very simple thing to do. You now store your defaults out the way in the backend.

All the manager needs to be able to set is the value stored in that config table.  Then you adjust your form to read that value when it loads and set the visibility according to the value.

Glad to have been of help.
0
 

Author Comment

by:waverobber
ID: 40403258
Roger that...Thanks
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses
Course of the Month7 days, 21 hours left to enroll

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question