MS Access Office 365 keeps crashing when opening a popup form - ms-access

I am using a windows 7 Enterprise 32-bit operating system and Microsoft Access 365 ProPlus.
I open a form then when I double click on a field it triggers an event procedure that opens another form. This form is a Pop Up form (non model) single form default view. Everything was working great for the last year or so and for some reason when I open the form this way the access program crashes.
I can open the form by selecting it from the search forms dialog.
What I found works is I need to open the form then edit it in design view. Make a small change in the form and save it. Then view it in form view and close the form. Once I have done all this I can run my program normally and everything works great until I close access and re-open it. Then I need to do it all over again.
I have ran the compact and repair tool several times.
My code is a very simple one:
On Error GoTo Err_Command18_Click
Dim intBuildingId As Integer
Dim StDocName As String
intBuildingId = Form_Frm_Buildings.Building_ID
StDocName = "Frm_Buildings_To_Frm_Manager"
Me.Refresh
DoCmd.OpenForm StDocName
Forms(StDocName).Recordset.FindFirst "Building_Id = " & intBuildingId
Err_Command18_Click:
Exit Sub
Any help would be appreciated and thanks in advance!
Mark

Related

Access 2016 set form field based on previous form value

I am creating an Access Database formed out of two things - Software and Licences. Licenses are attached to Software via their ID.
I have a form created for Software, and would like to create a button that, when clicked, opens a fresh "Add License" form which pre-populates the Software ID and that people can fill in the rest of the information on.
I've been using Macros from a similar Office 2016 Template and it continually falls over when trying to put this information into the new License form.
I've attached a screenshot of my macro below - I've gone through many iterations of this now and the error I get is 30024, which appears to indicate that it cannot find the field to put the SoftwareID into in the newly opened form.
I've also set the "Control Name" to just "SoftwareID" as this was also suggested elsewhere but this also does not work.
Any suggestions?
Screenshot of Macro in question
I couldn't get it to work using the embedded macro so I used a VBA macro instead which worked :). To do this (assuming you haven't done it before):
Open your "Software" form in design view
Show the property sheet (Ribbon -> Design Tab)
Click on your button
Click the "Event" tab on the Property sheet
Delete the "On Click" event
Right click your button and click "Build Event"
From the "Choose Builder" popup box, click "Code Builder"
Assuming you don't have any other macros, your code should look just like mine with the only differences being the name of your button (mine is Command163)
p.s. I Couldnt get the code tags to display properly so i just added some line breaks. Apologies for the improper indenting.
Option Compare Database
Private Sub Command163_Click()
DoCmd.RunCommand acCmdSaveRecord
openFreshAddLicenseForm (Me.ID)
End Sub
Public Function openFreshAddLicenseForm(ID As Integer)
On Error GoTo Macro1_Err
DoCmd.OpenForm "Add License"
DoCmd.GoToRecord , "", acNewRec
Forms![Add License]!SoftwareID = ID
Macro1_Exit:
Exit Function
Macro1_Err:
MsgBox Error$
Resume Macro1_Exit
End Function

Cannot close and reopen Form in Access (OLE Connetion)

I'm a VBA noob but maybe you can help:
I want to refresh all Forms (subforms) and queries on my Main Form "FinalForm". However I use Access as a frontend to SQL server. So apparently the usual buttons (created with the wizard, like refreh, new record etc.) won't work.
I created a (stupid) workaround by closing and reopening the form:
Private Sub Befehl71_Click()
DoCmd.Close acForm, "FinalForm"
DoCmd.OpenForm FormName:="FinalForm"
End Sub
This works fine within the vba editor but fails if triggered by button (something about an ole communication error).
How can I fix this ?
The standard VBA procedure is
Me.Requery
For a subform only
Me.PUT_SUBFORM_NAME_HERE.Form.Requery

take a snapshot with a webcam from ms access form

i need to take a snapshot with webcam when someone press a button in access form.
Is it possible?
i know how open a program from access but i'm stuck on how to trigger the event
the code
Private Sub Command1_Click()
Dim stAppName As String
stAppName = "C:\Program Files\myapp"
Call Shell(stAppName, 1)
End Sub
now let's say the snapshot trigger by f12 key in the app
how do i get the f12 key to click automatically
ok i got it
if any one want to know here is the method
1.by 2 macros "runapplication" & "sendkeys"
with "runapplication" just put the path of the app
with "sendkeys" just put the command SendKeys "{yorkey}"
by the way you need to press show all command in the the toolbar
or you can do it in vba code
You could try this if you are in windows 8/8.1
Dim cameraPath As String
cameraPath = "shell:AppsFolder\Microsoft.MoCamera_cw5n1h2txyewy!Microsoft.Camera"
Shell "explorer " & cameraPath

How to present a MS Access Form to the end user?

I created a form in MS Access. Unfortunately I cannot publish to access services or make a package solution
I am looking for a user friendly way to present this form to the user. So far the user will open the ms access file , click on the form and fill it out.
I would like to have a way to provide the form ONLY. I do not want the user to see all the tables and the structure . . Is there any way i can separate the form from the tables, queries etc. list ?
I split the database, and gave a fe copy to the user, but it still sucks! All those panels and stuff. Does MS Access has anything to address this issue ?
The issue(s) of splitting the database, and the issues of creating a compiled accDE are NOT ONE BIT RELATED to hiding the Access interface.
100% separate question and issue.
Now, without question the above should be done for any access application, but THE ABOVE HAS ZERO TO DO WITH hiding the access interface.
Once you get the access UI hidden, then you can consider the idea of compile to accDE a good idea to PREVENT users from getting into the access UI parts.
Same goes for splitting. You really need to split. However, AGAIN the splitting has NOTHING to do with hiding the accsss interface.
So now, lets get on to hiding the access interface.
To hide all of the access interface and ONLY show the form, you need to add ONE LINE to your start up code (the forms on-load event is fine).
So, specify the form you want to display in the options.
Add this ONE LINE of VBA code to the forms on-load event.
DoCmd.ShowToolbar "Ribbon", acToolbarNo
The additional settings you require are:
[x] Display Navigation Pane <-- uncheck this box.
[x] Use Access Special Keys <-- uncheck this box
Set access to use tabbed interface, and un-check the box to display tabs.
The form MUST NOT be popup. It can be model, but NOT popup.
The result is you will ONLY see the form. This shows the result:
Now keep in mind to get back to "developer" mode, you have to exit, and then hold down the shift key during startup. When you get all of this working, then you want to compile to an accDE, and search out some answers on how to disable the shift key during startup to prevent your users from seeing the access UI.
So you ONLY need one line of code to achieve this goal. The rest is just choosing the correct settings in your application, and that one line of code on startup.
Steps for publishing the compiled accde file and making it ready for end user:
BackUp: Take backup of your accdb/mdb file
Uncheck following elements from Database Options
(Office Button=>Access Options=>Current Database) :
Display Navigation Pane
Allow Full Menus
Allow Default Shortcut Menus
Security: To prevent anyone bypassing the start-up by using the Shift key and access the table use below code :
Public Function DisableByPass()
On Error GoTo err_proc
'Disable By Pass Key in mde/accde db
Dim dbs As DAO.Database
Dim prp As Property
Dim strMDE As String
Set dbs = CurrentDb
With dbs
On Error Resume Next
strMDE = .Properties("MDE") 'If this is an MDE or ACCDE database, disable bypass key
If Err = 0 And strMDE = "T" Then
.Properties("AllowByPassKey") = 0
If Err.Number = 3270 Then
On Error GoTo err_proc
Set prp = .CreateProperty("AllowBypassKey", dbBoolean, False)
.Properties.Append prp
.Properties.Refresh
End If
End If
End With
exit_proc:
On Error Resume Next
dbs.Close
Set dbs = Nothing
Exit Function
err_proc:
MsgBox Err.Description
Resume exit_proc
End Function

Running VBA code on an event in an Access web database

I took a already set up database from the Office.com templates (File --> New --> Office.com Templates), since this template already gave me 80% of my requirements.
I then changed the last 20% of this template where I came into the following: It seems as this template is a web database. I am not sure about the differences of a web database and a normal database in Access at all but I did find out, they do not allow me to run VBA code. At least not when I am trying to call it by an event.
Is there any way to achieve this anyways? Or are there possibly any other ways, such as converting the web database into a normal one perhaps?
Actaully, you can call VBA code from the forms event code. However, it requires a bit of a kluge.
However, you don't need to do this in your case.
Do note that you can create client objects and use client VBA code in your web application.
This means you can add/mix VBA forms into that application (these client objects of course cannot run in a web brwoser, but they can be used the client).
Suggestion #1:
to hide record navigation buttons.
Open the web form in layout mode. Move a object (dirty the design).
Whack ctrl-g for VBA command prompt. Type in this:
forms(0).NavigationButtons = False
Now, save the form. The record navigation setting will be saved with the form.
Suggestion #2:
Open the web form with VBA. Use this code:
DoCmd.OpenForm "AssetsDetails"
Forms("AssetsDetails").NavigationButtons = False
Suggestion #3:
Call VBA code from the forms load event. This is a bit of kluge, but does work:
In the forms open event, place this macro code:
OpenForm (frmRunVBA,,,Dialog)
Note that in above WEB MACRO editor the VBA form above called frmRunVBA does NOT appear in the drop down choice list - but you CAN TYPE/force in the name – this is legal.
Now create a VBA form called frmRunVBA). In the forms load event, palce this code:
Private Sub Form_Load()
Forms("AssetDetails").NavigationButtons = False
DoCmd.Close acForm, Me.Name
End Sub
So you can call VBA code, but you really don't need to if you use tip#1.