MS Access VBA Compile Error on "x=" - ms-access

Everytime I try to compile my VBA code, I'm getting an error that says "Can't find project or library".
I have no idea which library I'm missing because all that the debugger highlights is a portion of one of my VBA lines:
x=
the full line looks like this:
x = MsgBox("You must select a manufacturer")
Any clues what library I need to include?

Thanks Hans,
I didn't notice that one of my references was labeled as "MISSING".
...
First thing to check: from VB Editor main menu, choose Tools->References. If any of the selected (checked) references are "Missing", all sorts of weird crap can happen with your code. Fix any that are missing

Related

How to preview a Source Assistant SQL Command with parameters

TL;DR: A data flow task "works" when the package runs, but I am unable to view the query when clicking "preview" in the Data flow Source Assistant.
My working theory is that somehow the Source Assistant is unable to get the value of the parameter when previewing. I tried to resolve this problem by use of (iterations) "Parameter" and "Variable" without success. The example shown below use "Parameter".
In an SSIS Data Flow task, I have a Source Assistant with "SQL Command" as its data access mode.
SELECT h.Campus,
h.StudentName,
h.StudentId,
h.EntryDate
FROM dbo.RwsBaseEnrollmentHistory h
WHERE h.Campus = ?;
The question mark indicates a parameter, which I have defined in "Parameters".
In the OLE DB Source Editor, I made sure to map the variable to the parameter.
When I click "Preview" I get an error:
The data in question cannot be shared, but trust me when I say that when I run the package, the query works as intended. It's the inability to preview the query that I'd like to be able to fix.
What do I need to do so that I can preview the query without having to hard-code the parameter value?
I stumbled into a possible answer. It appears to work so far and I haven't been able to break it. If there is a better way of doing this I would love feedback.
This is my resolution:
Create a variable to hold the desired query (like shown in the example above). In this example, I name it EnrollmentHistory.
In the "Expression", click the [...] button and paste the query. Be sure that double-quotes surround the query.
"SELECT
h.Campus,
h.StudentName,
h.StudentId,
h.EntryDate
FROM dbo.RwsBaseEnrollmentHistory h
WHERE h.Campus = '" + # [User::Campus] + "'"
Press the "Evaluate Expression" button and press OK.
Go back to your Source Assistant and select "SQL Command from Variable" as the Data Access Mode and the Variable you just defined (in this case EnrollmentHistory) as the Variable name. You will see that the parameter is correctly resolved in the Variable Value.

There was an error compiling this function. Access 2013 Calculated field issue

I have a table with a field which is of a calculated type and contains the following expression:
IIf(IsNull([OrderValue]),[TotalPhaseLabourCost]-[DefaultOrderValue],[TotalPhaseLabourCost]-[OrderValue])
For some reason when I go to open the table in any view it throws the error:
"There was an error compiling this function.
The Visual Basic module contains a syntax error.
Check the code, and then recompile it."
However, I have this database currently open on two laptops, one works fine and the other has this issue. I have checked both db's refs and they also match up.
That's a bit vague, so I can only make guesses.
Try to compile the code as the error message says.
check if you have any function with the same name as your field
Try replacing IIf(IsNull([OrderValue]), by IIf([OrderValue] is Null,
You probably miss the leading equal sign:
=IIf(IsNull([OrderValue]),[TotalPhaseLabourCost]-[DefaultOrderValue],[TotalPhaseLabourCost]-[OrderValue])
Or you could use:
=[TotalPhaseLabourCost]-Nz([OrderValue],[DefaultOrderValue])
For me there was some problem with some fields (it showed an error message #NAME? in some of the fields (date, number) in the 'new' record).
For me it worked to close the table, right-click it and open in design view.
For each of the fields with problems, I choose the data type (that was already shown) again from the drop down menu (so, same data type!).
Save.
Then it didn't give the error messages anymore.

Complie Error: Method or Data Member not found, but it does exist

Having a strange problem in vba access. I have a text control control called txtUserName on a form and am trying to get the contents which is all but child's play. When I try to run or complie, I get the Method or Data Member not found error. However, when I type me. Intellisense shows txtUserName. I have gone as far as copying and pasting the name from the control's properties and still get the error. What am I missing? I am completely perplexed.
Thanks in advance
Don
In this case, I was just building a SQL string. I did find the problem, there was a bad control reference, however, it was not the one that was highlighted (highlighted was the first value in an insert into string and it was actually the 3rd value)

NotInList script

I am trying to use Access and VBA to create a DB to store my library. I already posted a question and got a useful answer but I am still failing with the basics, so, after having checked this tutorial link I am starting from scratch and doing it in smaller steps (i.e. asking more basic questions...).
I have the following DB structure and relationship details:
DB structure and relationship details http://img195.imageshack.us/img195/8184/relationshipdetails.png
Using the Access AutoForm:Columnar wizard I created a Form based on the Table Libri, then I changed the field "Stanza" into a ComboBox, I entered the RowSource as follows:
ComboBox http://img560.imageshack.us/img560/160/comboboxdata.png
Then in the Event tab I selected the ... controls in the NotInList and in the VBA I entered the following code:
VBA code http://img689.imageshack.us/img689/1416/notinlistcode.png
Saved everithing, but when I open the Form Libri and try to enter a value in the ComboBox I get the following error message:
Error message http://img41.imageshack.us/img41/8937/errormsgt.png
All my tables are empty (no records).
So the VBA code seems not to be considered/executed at all, what am I doing wrong or missing?
Ok, I was completely blind.
The error is the option: "Limit to list" that I set to "NO" and instead, the NotInList event is only filred if such option is set to "yes".
I find this conter-intuitive, but at least now I know.
Sorry for bothering other. hope this is helpful some other newbe like me.

Error on declaring current date (vb for office)

the code of my my form is this:
Dim dtmTest As Date
dtmTest = DateValue(Now)
and the error is: external procedure not valid.
it highlights the word now
Just use:
dtmTest = Date()
Or, for date and time use:
dtmTest = Now()
From the above, it seems that have a missing or broken reference. Look at the references (code window, tools->references) and check if any are marked missing, if there is one, untick it and look for a suitable matching reference. (http://support.microsoft.com/kb/283806)
It is generally best to use late binding in production, because the libraries for the various Office products, such as Excel, frequently reference, vary from PC to PC.
If you do not find a missing reference, you can try to delete the VBA library itself - it will not let you, but for some reason, this seems to help.