Microsoft office can't find the object "A_Z Schaltfläche" - ms-access

I migrated a database from access 2003 to access 2007.
It seems to work but when I clicked the buttons from A-Z I'm getting this error message:
"Microsoft office can't find the object 'A_Z Schaltfläche'
If 'A_Z Schaltfläche is a new macro or macro group, make sure you have saved it and that you have typed it's name correctly"
I didn't make a new macro but I deleted a word in one of the tables which I think causes the problem: "Like [Formulare]![Frm_Fahrzeugdaten]![Schaltflächenkriterium]"
I found it under the "Record Source" and under one field, that expression is written in the criteria field. If I don't delete this I'm getting a box which says: "Enter Parameter Value" Formulare!Frm_Fahrzeugdaten!Schaltflächenkriterium
My skills in VBA is not really so good, and I need some help how to correct the problem
Thanks for your help.
=======
additional info's:
When I open the VBA code under the Form_Fahrzeugen, here is what I saw:
Private Sub Auswahl_Click()
On Error GoTo Auswahl_Click_Err
' Programmablauf
Me.Filter = "[A_Fahrzeugtyp] like '*'"
Me.Namen_Filter.Value = 27
Me.Schaltflächenkriterium = "*"
Schaltflächenkriterium = "*"
Me.Requery
Me.lfd_Name.Requery
DoCmd.GoToRecord acDataForm, "Frm_Fahrzeugdaten", acGoTo, 1
Me.lfd_Name.Selected(1) = True
Me.A_Inventarnummer.SetFocus
GoTo Auswahl_Click_End
Auswahl_Click_Err:
Call ErrorHandler("Form_Frm_Fahrzeugdaten", "Auswahl_Click", Error$, Err, Erl)
Resume Next
Auswahl_Click_End:
'Ausführungen vor den verlassen der Routine
End Sub
Does it have something to do with the macro name? This is the macro name by the way: "A_Z Schaltfläche"
If I go to the design view of "A_Z Schaltfläche" this is what I got, the conditions are marked yellow I'm not really sure if this is a good sign though:
Thanks
==============
Updates about my problem:
I was able to find the solution of my problem. It was the version of my microsoft office which was causing it. The original database was written in German and when I did the migration, I migrated it to the english version of Access 2007. The reason why it can't find the object because of the name "Ereignisprozedur" in German and "Event procedure" in English. I changed it to Event Procedure because the error says:
"Microsoft Office Access can't find the object "Ereignisprozedur"
If Ereignisprozedur is a new macro or macro group, make sure you have saved it and that you have typed its name correctly
Access was unable to locate the macro or VBA function. If you are trying to call a macro, make sure that the name of the macro and the name of the macro group are spelled correctly.
If you are trying to call a user-defined VBA function, be sure to use the following syntax:
=FunctionName() or =FunctionName(argument1,argument2,...)
Make sure that the function is either:
Defined in the code for the form or report.
- or -
A public function that is in a module (not a class module)."
And the word "Formulare" to Forms. Then the program works.
I can't understand why microsoft programs are language independent???

Do you mean you deleted a word in one of the Queries? What it is is a reference to a form called Frm_Fahrzeugdaten and a control (field, column) called Schaltflächenkriterium. It is under criteria, so the query is saying:
Select such and such where this field (column) is Like this form and this control
It is usual to have
Like "*" & [Formulare]![Frm_Fahrzeugdaten]![Schaltflächenkriterium] & "*"
Or
Like [Formulare]![Frm_Fahrzeugdaten]![Schaltflächenkriterium] & "*"
That is, with wild cards (*)

[Schaltflächenkriterium] seems to me to be the name of an edit control (textbox) in form [Frm_Fahrzeugdaten] for the user to filter a record set.
If you deleted the textbox control, just re-insert it and name it correctly.

Related

MS Access run code after a row is updated

I am very new to MS Access, forgive me for this simple question but I am very confused with my current problem.
So I want to run a VBA function after a table receives an update on one of its fields. What I have done is:
Create a Macro named Macro_update under CREATE->Macro, with action RunCode, and its argument is the VBA function I wish to run. The function has no bug.
Select my table, and under Table->After Update, I wrote
IF [Old].[status]=0 And [status]=1 THEN
RunDataMacro
MacroName Macro_update
But after I update my status field in my table nothing happened... I am suspicious of the fact that in step 2 my action is RunDataMacro, but I am actually running a Macro (is there a difference?)... any help is appreciated!
You can use a Data Macro to get it working locally for now. This means that the table will need to be stored in an Access database.
If your web service is not actually using the Access Runtime to interface with the access database container, then the data macros may not fire correctly nor as intended. Your mileage may vary.
If you later migrate your database to a SQL server (MySQL, Microsoft SQL, PostgreSQL) then your data macros will need to be implemented natively on the SQL server as a Trigger.
For now, I'm writing some instructions below to demonstrate how to call a VBA function from a Data Macro locally within a single Access database:
Create the VBA Function This will be the function that you want to call from the data Macro.
Create this in a Module, not in a Form or Class Module.
This has to be a function and cannot be a sub
Code:
Public Function VBAFunction(OldValue As String, NewValue As String) As String
Debug.Print "Old: " & Chr(34) & OldValue & Chr(34);
Debug.Print vbTab;
Debug.Print "New: " & Chr(34) & NewValue & Chr(34)
VBAFunction = "Worked"
End Function
Create the Data Macro (Going to be more descriptive here since people get lost here easy)
Open the Table (i.e. TestTable) in Design View
Find the correct Ribbon
In table design view, there is a contextual ribbon called Design.
On that ribbon, there is an option called Create Data Macros
Click on Create Data Macros and select After Update
The Macro Designer window should now open
Choose SetLocalVar from the Add New Action combo box
A SetLocalVar section appears.
In this section, I see Name and Expression
Set Name to an arbitrary value, such as: MyLocalVar
Set Expression to the following
Be sure to type the = sign, which will result in two equal signs being shown
Expression Text:
=VBAFunction([Old].[FieldName],[FieldName])
Save the Data Macro and Close the Macro Designer.
Save the Table and Close the Table
Test It: Create an Update Query
Next you will need to create an Update Query that performs an update on the Table that houses the Data Macro you just created.
To test this, you can just update a string field in all records to one value.
UPDATE [TestTable] SET [TestText] = "Test"
Run the query
Press Control + G to bring up the Immediate Window. You will notice that the Data Macro fired for every updated record.

How can I create a control on an Access report via VBA?

Until now, I manually created a finite number (12) of controls on a report and my code, essentially, turned them on or off (successfully) based on how many the user chose.
Now my client wishes the user to have "no limit" to the number of controls on the report.
My strategy is to delete the controls and create the required number on the fly (via code).
However, when I try to create a control, I get the run-time error 2450 "cannot find the referenced form".
Snippet:
DoCmd.OpenReport "My_report", acViewDesign
Dim ctl As Control
Set ctl = CreateControl(FormName:="My_report", ControlType:=acTextBox, _
Section:=acDetail, left:=2880, top:=0, width:=967, height:=312)
' ... here lies code that adjusts attributes of the controls
DoCmd.OpenReport "My_report", acViewReport
Execution halts on the CreateControl line: ... cannot find the referenced form 'My_report'. (When working, the actual CreateControl code will be in a loop and geometry parameters replaced by variables.)
All discussion I've seen relates to forms but the documentation at CreateControl Method says the first parameter is the "name of the open form or report on which you want to create the control" so it should work for reports too.
Note that the report is open in design mode. Any idea what I'm doing wrong?
Online help / documentation is unfortunately wrong or at least misleading sometimes.
There is a separate method CreateReportControl() for this.

How can I check if an attachment field is empty or not in Access?

I am having some trouble with MS Access 2010. I am trying to modify a database I downloaded, a template from Microsoft‘s web site, I am doing a little modifying to keep track of the food nutrition. I have some experience with basic from the old days of the 16 bit Atari days. I’m not totally green to VBA, just know enough to get in trouble. I have a Form that uses a select query to populate lower half of the form. I added an attachment field to the foods table which has over 8500 record that is the table for the query. My problem is to add VBA code in a module to see if there is a photo present or not. I want to be able to show an icon grayed out for no photo and a regular icon if there is a photo file. But that's for when I get it work to begin with. I call the function in the field properties:
Photo1: chkAttachment([Photo])
This one to start with gives me and error saying: "The multi-valued field '[Photo]' is not a valid in the expression 'chkAttachment([Photo])'. When I change it to:
Photo1: ChkAttachment([Photo].[FileName])
I get and #Error for the empty fields and a "Has Photo" for the one with a file in it.
The Following code is the function I am referencing To Show what I am trying to do
Public Function chkAttachment(fldPhoto As String) As String
On Error GoTo chkAttachment_Err
chkAttachment = ""
'Debug.Print fldPhoto
If fldPhoto = Null Then
chkAttachment = "No Photo"
Else
chkAttachment = "Has Photo"
End If
chkAttachment_Exit:
Exit Function
chkAttachment_Err:
MsgBox " It don't like Error number: " & Err.Number & " " & Error$
Resume chkAttachment_Exit
End Function
The query won’t even call the code if the attachment is empty. I Googled the following question, and searched on this web site “Microsoft Access 2010 VBA how to query attachment field” without any luck. I have tried to use some code to count the number of files in the attachments, I found in the thread “How to query number of attachments from Attachment field in Microsoft Access?” from Aug 2011, but couldn’t figure out how to get it to work. When it comes to SQL, I’m in the dark with that part.
Thanks for any help that comes my way.
Steven
If you have an Attachment control named [attachPhoto] on your form and that control is bound to the [Photo] field (i.e., the Control Source of the Attachment control is Photo) then you can just check the value of
Me.attachPhoto.AttachmentCount
to see if the record has any attachments.
(Note that if you don't want the users to actually see the [attachPhoto] control you can just set its Visible property to No.)
You can check it in SQL statement " Not (tblxx.Pic.FileData) Is Null " probably in the where clause. I did it this way using a recordset.
I believe this is causing the #ERROR in your field
If fldPhoto = Null Then
Correct checking for Null would be the following:
If IsNull(fldPhoto) Then
But then you might still get a Null exception while calling the function. So you might want to edit your overall code to the following:
If (fldPhoto = "") Then
and when calling the function :
Photo1: ChkAttachment(Nz([Photo].[FileName]))
Hope I helped
I wanted to check if an attachment was made or not before running a query on a form. I made a text box in the form and under control source of the text box, went to expression builder and entered " = [name of column which has the attachment].[AttachmentCount]".
The text box gave me the count as 0(zero) if no attachment is made and 1 for 1 attachment. I could use the text box to condition run my query. All the above in Access 07.

Save Record built-in macro with custom confirmation dialog

I was wondering if anyone knew how to create a custom message for the save record confirmation, only using macros and not user coded VBA. I've done this for a previous project in VBA but this time I'm trying to only use Access' macro builder. I'm using Access 2010 to build this project.
So far I've got
IF 6=MsgBox("Are you sure you want to delete this customer's information? WARNING, this is unrecoverable."),52 Then
RunMenuCommand DeleteRecord
MessageBox Message "Customer information deleted."
This makes a yes no dialog box first as the confirmation but it then shows the built-in confirmation that Access bundles with the DeleteRecord command.
Thanks,
Jake.
don't use the run menu command. You could for example delete using SQL
currentdb.execute "DELETE * FROM myTable WHERE myTableId=" & idOfRecordToBeDeleted
Looking for a similar solution myself and after much ado, have a solution. Using Access2013, but should be the same logic.
In my case, I wanted a Yes/No message box to add a record on Yes, and reload the form on No. In your case, leaving out the filters and values, it would be simpler... If yes, RunMenuCommand = Delete Record Else StopMacro. You could set up the specifics for No, but Else handles it for me.
Specifics: I have a form with a combo box (macro is tied to the combo box/After Update property) to select and filter the records. If there is a matching record(s), display it(them). If there is no matching record, display a message (no records) and prompt the user to add one (yes) or not (no).
The entire macro.... (no VB)
ApplyFilter
Filter Name (blank)
Where Condition =="[cID]= "& Str(Nz([Screen].[ActiveControl],0))
Control Name (blank)
If IsNull(eID]) Then
If MsgBox("No record",4,"Nothing found")=6 Then
SetProperty
Control Name cID
Property Value
Value =Str(Nz([Screen].[ActiveControl],0))
StopMacro
Else
RunMenuCommand
Command RemoveAllFilters
StopMacro
End If
End If

MS Access just stopped recognizing it's own text box exists

An MS Access form that has been working for over a year now, does a simple:
"Dim MyQuoteID as INTEGER
MyQuoteID = Me.QuoteID"
(It then proceeds to execute an SQL Statement inserting "MyQuoteID" that it just captured from the form)
...Only now it errors and says "Method or data member not found" on "Me.QuoteID".
Of course, the "QuoteID" box is right there, plainly visible, and has been for over a year.
Obviously some kind of corruption because I didn't change anything - but it doesn't solve with a compact and repair!
WTH??????
Two things to try:
Decompile via the command line (msaccess.exe "path\to\your.mdb" /decompile)
Use the undocumented SaveAsText and LoadFromText methods to "export" and "import" your form
SaveAsText acForm, "YourFormName", "YourFormName.txt"
LoadFromText acForm, "YourFormName", "YourFormName.txt"
I think you meant to write TextBox rather than INT. Assuming that this code is in the VBA module for a form, you do not need to define any of the controls in this way, nor is it good practice to do so. Just delete these two lines, and it might fix your problem.