Update a specific cell in MS Access using visual basic - ms-access

good day, i would like to ask if it is possible to update a specific cell in ms access using visual basic. If it is possible, may i ask what would be the syntax to be used? Thanks!

Yes, it is possible.
The syntax would simply be an Update Query.
When you say "..using visual basic". I am interpreting that as using Visual Basic for Applications. Am I correct?
You can either create the query using QBE, and pass in the parameters in the Criteria field within the query.
You could then run the query via code:
DoCmd.OpenQuery "YourQueryName"
MS Reference
If that's not your preferred way, you need to look into constructing SQL strings into VBA.
Check out this StackOverflow question. String concatenation in VBA is different than just writing SQL in Access.
Hope this helps.

Related

Excel VBA using SQL Datediff

Hi I have an Excel sheet with quite a number of data inside, and now I want to perform queries directly in the sheet using VBA. One query is to find the recurring users, so when I implemented it in MySQL I used the DATEDIFF function, so is it possible to do this in Excel? I've tried to embed the SQL statement into VBA, but it failed. Thank you!
My original SQL statement is like this:
select max(logtimestamp), min(logtimestamp), count(logtimestamp), username
from report
group by username
having datediff(max(logtimestamp),min(logtimestamp))>=14
order by count(logtimestamp) DESC;
And it works in MySQL.
EDIT:
I'm currently using ADODB in VBA to embed the SQL queries. Some simple queries have already been implemented, so I suppose my configuration is correct; the problem now is I don't know how to get this SQL query into VBA. It's now giving an error, and it might be related to the DATEDIF (different from DATEDIFF in SQL) function in Excel.

Can I obfuscate the SQL code in MySQL?

I'm trying to find some way to obfuscate SQL code in MySQL.
In the Oracle databases exists the "wrap" funcionality, but I didn't found some similar. Some ideas?
The final goal is that the client has some difficuties to understand the code.
I think MySQL do not have the ability to obfuscate the code. You can encapsulate the whole SQL query code by creating a STORED PROCEDURE, although not encapsulated but at least your whole SQL query is not shown when used inside your code (PHP, .Net, and the like...).
MySQL does not have any obfuscation abilities - you could write some code that would be confusing to read by having some other table with defined values that you could use IF statements against to make your code difficult to read...
SELECT co1, co2, IF(3 > 18, co3, '') AS co3 FROM table INNER JOIN...
etc... or using COUNTs as parameters in conditional statements is as best as you're going to get (obviously performance may become an issue depending on how "obfuscated").

How can I query XML data in SSRS / VS 2008?

I have a report query using a lot of WITH XMLNAMESPACES to query some XML data in SQL Server 2008. It doesn't look like i can create a report in VS 2008 using this query because of the xml querying. If I'm reading MS's whitepaper correctly, you have to pull the XML out and then do a separate query against it? Anyone have any experience with this, or is there a better way?
And this is an issue of misinterpreting errors. The real issue in my query wasn't the use of WITH XMLNAMESPACES, but the use of "sql:variable("#varName") in the WHERE of my XSL. Easy way to solve that is to add a DECLARE #varName in the query and set it to the passed in parameter. After that, it worked like a champ.

MS Access queries

I must understand few things about MS access queries, and this is why I'm coming here.
First of all - my task list is written in Latvian (hate that), this is why I can't understand simple things.
Here is my one of tasks: "Make four simple queries, where shows specific, not-specific, number intervals, less than and greater than."
Probably I didn't translated my task correctly, but I can't understand, what does means specific and not-specific query.
This is too simple for me, and this is why I don't get it.
And also I wanted to ask, if there is any SQL commands, which does the same thing like in PHP function substr(). As I tried to use SQL commands, which I use daily writing MySQL queries, does not work in MS Access.
I hope, that some one could help me about this :) Thanks!
/Rob
Here are some references that may help:
Fundamental Microsoft Jet SQL for Access 2000
Intermediate Microsoft Jet SQL for Access 2000
Advanced Microsoft Jet SQL for Access 2000
As for substr, you can use Mid, Left, Right, InStr and InstrRev.

Migration issue from MS-Access 2003 to MS-Access 2010

I work for a company where we likely going to update from Access97/2003 to Access2010.
After playing around with a prototype, I have found an issue when using Access 2010 with databases created in Access 2003.
Under some conditions, existing queries/SQL's in Access 2003 will become unusable in Access 2010. Here a small example:
Tablename: Parameters Field names: Number, Value
A query created with Access 2003 query designer:
SELECT Parameters.Value
FROM [Parameters]
WHERE (((Parameters.Number)=100));
this works fine with Access 2003.
In Access 2010 a error is raised: Syntax error in PARAMETER clause
A workaround for the error is to change the view in Access 2003. Here we get rid of the brackets:
SELECT Parameters.Value FROM [Parameters] WHERE Parameters.Number=100;
This will work in Access 2010 but the query remains unchangeable in the designer, because the query designer creates the syntax shown above.
The reason for this error is in fact the use of the reserved word 'Number', which shoudn't be used when you start to build a table or query, but for a migration with hundreds of existing databases, it is very likely or at least a risk to change the Access version without a complete test.
My idea is to write a small program which opens all the existing views and the tables to check if they work fine.
Anyway, dose anybody have a better solution for this, or is there a tool to check MS-Access 2003 databases to be compatible with Access 2010?
Many thanks in advance
Jörg
Parameters, Value, and Number are all reserved words. You may be right that Number is the culprit here; I would have suspected Parameters as more likely to confuse Access in a query.
"For a migration with hundreds of existing databases", first evaluate them with Allen Browne's Database Issue Checker Utility. In addition to the reserved words issue, it will give you an idea of other potential problem areas. Whether those issues will be more troublesome in Access 2010 than in 2003 is an open question.
However I don't see an easy solution for your predicament. You have hundreds of databases with perhaps thousands of tables and queries ... if they routinely incorporate reserved words for table and field names, as well as other object names ... your situation is miserable.
Experiment on a copy of an existing database. Turn on "track name autocorrect" and let it build the object dependencies. Change the table definitions to eliminate reserved words. Then see how much extra work you need to find and fix the items autocorrect didn't do for you. But don't leave autocorrect turned on in any application you release to your users.