Showing posts with label Modules / VBA Code. Show all posts
Showing posts with label Modules / VBA Code. Show all posts

7/31/2012

Renumber invoices with VBA code

no image Question: In Access 2003/XP/2000/97, I have a database which contains a large number of records. Each week, I need to renumber the INVOICE NUMBER field in a table named DATA with a new batch of numbers.
Answer: You can renumber your invoice numbers using a custom function.
Open your Access database, click on the Modules tab and create a new Module. Paste in the following

7/18/2012

Retrieve the user name from Windows while in a database in Access

Retrieve the user name from Windows while in a database in Access Question: In Access 2003/XP/2000/97, how can I retrieve the name of the user logged into Windows?
Answer: To retrieve the user name from Windows, create a new Module in Access.
Paste the following code into the Module:

7/15/2012

Access a value from a table using VBA code

Access a value from a table using VBA code Question: In Access 2003/XP/2000/97, how can I access a value directly from a table using VBA code?
Answer: To access a value directly from a table using VBA code, you first need to create a new Module. To do this, open the Database window, select the Modules tab and click on the New button.

7/03/2012

Connect to Oracle using VBA code

Connect to Oracle using VBA code Question: I'm developing an application using Access 2003/XP/2000/97 as the front-end and Oracle as the back-end database. I've run into an scenario wherein I'd like to suppress the "ODBC Driver Connect" window prompt that asks for the username and password to connect to the Oracle database.
So I've created a form called "Login", but I need help writing the VBA code that would connect to Oracle. Can you help?
Answer: To connect to Oracle as you described above, you'll have to first create an ODBC connection to your Oracle database using the {Microsoft ODBC for Oracle} driver.

Link to an Oracle table using VBA code

Link to an Oracle table using VBA code Question: In Access 2003/XP/2000/97, I'd like to link to an Oracle table using VBA code. How can I do this?
Answer: The first thing you need to do is create an ODBC connection to your Oracle database using the {Microsoft ODBC for Oracle} driver.
To do this, go to the "Data Sources ODBC" icon under the Control Panel and create a new Data Source using the {Microsoft ODBC for Oracle} driver.