Using external database for excel application.

lemaao

New Member
Joined
Jun 25, 2015
Messages
15
Hi all,

I have developed a rather large application with VBA that we use at work. The problem with this is that the database is now in the excel application, and that means that no more than one person can use the application at a time. This is normally ok, but I thought I would try to fix this issue.

I want to use an external database, and just use excel/vba as a front to manipulate data in the database.

The application can now register new cases/rows in the database, search for old ones and change them, send e-mails, print statistics etc. I would like it to be able to keep doing this.

I have considered two options.

1. A CSV database.
2. An Access database using SQL(ADODB).

I am having some issues with choosing what database to go for, so I have been going back and forth, but I find it hard to find examples/information on what I need to do.

I guess I will start at the first issue I am having:

I want to open a database, find the last row used(case that has a reference nr), extract that number and +1 so that I can generate the next reference number for a new case.

Can anyone help with either the SQL(ADODB) or the CSV way of doing this?

This is the SQL code I have tried:
Code:
    Dim sqlConnect As ADODB.Connection
    Dim sqlRecord As ADODB.Recordset

    Dim cn As Object
    Dim rs As Object

    Set sqlConnect = New ADODB.Connection
    Set sqlRecord = New ADODB.Recordset

    sqlConnect.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=L:\Nett\Driftssentral\DRS\databaseDRS.accdb;Persist Security Info=False;"

    Set cn = CreateObject("ADODB.Connection")
    cn.Open sqlConnect

    strSQL = "SELECT [Varsler Navn] FROM [tblDatabase] WHERE [RefNr] = L50208 ;"

    Set rs = CreateObject("ADODB.RecordSet")
    rs.ActiveConnection = cn

    rs.Open Source:=strSQL, ActiveConnection:=cn, CursorType:=adOpenForwardOnly, LockType:=adLockOptimistic, Options:=adCmdText

    InputForm.refnr.Text = rs![Varsler Navn]

    rs.Close
    cn.Close
    Set cn = Nothing

I have just tried to find something to put in a text box basically. Not working....

I will take any advice on what database to use or tips on how to make any of the ways work ;)

Thank you for your help, and I apologize for the lengthy post.
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying

Forum statistics

Threads
1,214,923
Messages
6,122,283
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top