Error on declaring current date (vb for office) - exception

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.

Related

How to figure out the import rules for a given command?

So I'm looking at some access code, and trying to figure out what exactly it's doing. Semi-stuck at the following line:
SpecName = "DocLineDetailImportSpec"
DoCmd.TransferText acImportDelim, SpecName, tblname, filenm, True
Ok, let's do some googling. Microsoft tells us the following:
https://msdn.microsoft.com/en-us/vba/access-vba/articles/docmd-transfertext-method-access
Acimportdelin - ok, the default. Sure.
Specname - this is where I'm stuck
Tablename - yup, obviously going to the table named earlier
Filename - yup, obviously grabbing the file we declared earlier in the code
True - Sure, not too concerned about it.
So I'm on Specname - reading the documentation, it's a type of import rule. Ok, where are import rules kept? Apparently, in saved imports (from my googling). I get there and... there are two rules, neither of them have the name, and neither of them appear to have any sort of visibility. I can't see what they're doing (if they were even correct), or anything. How can I figure out (short of brute-force uploading data and tracing it all) what the speccommand is?
Uploading Excel files btw
Thank you
Your question, essentially, boils down to the following: how can I view the import specifications?
Well, in the following way (screenshots: Access 2016)
Step 1: Try to add a new data source -> Text
Step 2: Go to advanced
Step 3: Go to specifications
You can view and adjust import and export specifications here.

MySqlDataReader example with 2 sets of brackets

on the internet i saw an MySqlDataReader example.
It was saying something like:
read("products")("amount")
I know you can get data from field "product" from the reader by read("product")
but I didn't understand the second () set.
Nowhere info to be found about it.
Is it invalid syntax or a not documented option?
The .read method is used to advance the cursor forward. You can look up the spec online here: https://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqldatareader.read%28v=vs.110%29.aspx. I've never seen anything like that syntax myself and certainly the doc doesn't indicate it exists.
If you want to retrieve multiple column values in one go you can use .GetValues(). This will populate an array of objects so depending on what you want to do with the data you may need to cast them after retrieval.

Current Field Value into a VBA String Programmatically

I need to take the current value of a field from the record displayed on an open Access form and put the text in that field into a VBA string programmatically. This seems so simple but I have not yet been to find any guidance from either an aftermarket Access 2013 text I purchased or the Internet. I have tried everything I can think of with no success whatsoever so I posted a question on stackoverflow.com and received the following suggested solution:
Dim strYourString as String
strYourString = Forms![Your Form Name].[Field Name].Value
When this is run I get:
Runtime error ‘438’
Object doesn’t support this property or method
Any help will be greatly appreciated!
Try using a bang symbol in front of the field name, instead of a period.
strYourString = Forms![Your Form Name]![Field Name].Value
^---------------------Bang symbol here
This is supported by the documentation here on MSDN. Note the implicit form:
Forms!OrderForm!NewData
where NewData is the name of a control. Or you can use an explicit reference:
Forms!OrderForm.Controls!NewData
If you want to refer to a field in the underlying recordset of the form instead, use:
Forms!MyForm.Recordset.Fields("MyFieldName")

PowerBuilder Find function throws an error "expression is not valid"

What is wrong with this code. I am checking whether there is an available record in the database before inserting a new serial number. When I enter any record whether available or not, it throws an error message:
"Expression is not valid". (PowerBuilder Classic 12.5 and SQL Server
2008)
If This.GetColumnName() = "serial_No" Then
long ll_serial
ll_serial=dw_newrecord.find(data, 1, dw_newrecord.rowcount())
if ll_serial>0 then
messagebox("validation error", "The record already exists")
return 1
end if
End If
It is likely that your data expression has a syntax error. It can be some misformed code -like missing quotes- or maybe that the column name is incorrect.
To help for tuning a filter or find expression, you can test it in the datawindow design screen via the Rows / filter menu.
A better solution for long-term coding design would be to integrate the Datawindow Debug Machine (made by a colleague of mine) to your project. It is a precious tool to prototype datawindow expressions for finding, filtering but also for dynamic objects creation / modification in a datawindow. And while correctly interfaced with a datawindow ancestor of your project, it can help with filters and find expression errors like here.
EDIT: As RealHowTo noticed, the tool has been updated. Here is the current latest version (but there is no updated demo screencast though).

Snippet of code works on my PC, but not another person's

There is a bit of code I have written, which works on my PC, but doesn't work on someone else's. I am really confused.the code in question is
Dim temp As HtmlHtmlElement
Dim s As String
s = "2222222"
For Each temp In html.getElementsByTagName("option")
If temp.getAttribute("value") = s Then
r.Offset(0, 1) = (temp.innerText)
End If
Next temp
r is a Range object that is passed to the sub.
the variable html is an object that has been loaded with html from a webpage,using xmlHTTP
This code works fine on my pc, it finds the "option" tags in the html source , and then checks to see if the "value" attribute is equal to the string s. When I run it on someone elses pc , temp.getAttribute("value") returns a blank string, even though there is an attribute called value. The web page address is hard coded so its not that he's using the wrong URL
I use excel 2007, he uses 2010
Anyone got any ideas?
thanks
How have you declared and instantiated the html object?
For example, you say you're using xmlHTTP but is that the only option? Does your code try and Set html to "Microsoft.XMLHTTP" first and if not found then try "MSXML2.XMLHTTP" or even different version numbers ServerXMLHTTP30/ServerXMLHTTP60?
If so, perhaps the problem is that the specific reference hasn't been enabled and your fetching the webpage through different objects. Each of these can return a webpage slightly differently with different encoding, UPPER/LOWERCASE etc based on webserver settings and the object.
Edit: You may find this useful Using the right version of MSXML