Two questions: instr and table.column.value

U

Undrline

So, here's my simple code so far:

Dim mylocation, stAppName As String

mylocation = tbl_settings.Path.Value
stAppName = mylocation & "\backup\backup.bat"
Call Shell(stAppName, 1)

1) Apparently I'm not saying "tbl_settings.Path.Value" the right way (FYI,
the table only has one record)
2) I don't know the equivalent of InStr for VBA . . . but, I want to make
sure that the path was written correctly. I don't want to end up with
\\path\\backup\backup.bat or \\pathbackup\backup.bat or
x:\path\\backup\backup.bat or x:\pathbackup\backup.bat

Thank you.
 
V

Van T. Dinh

1. Check Access VB Help on the DLookUp function to retrieve a Field value
from a Table.

2. Check the last character of the retrieved value using Right() and if it
is "\", remove it from the retrieved value unsing Left() & Len().

All functions mentioned are well explained in Access VB Help.
 
U

Undrline

DLookUp() wasn't so well explained, but I was able to find a better
explanation, once I had the function name.

Right() worked perfectly.

Thank you!



So, for your edification, here is the new code:




Private Sub Command24_Click()

'Application.RunCommand acCmdBackup
' The above code, though it should work, does not. This is a workaround:

'CommandBars("Menu Bar"). _
' Controls("Tools"). _
' Controls("Database Utilities"). _
' Controls("Back Up Database..."). _
' accDoDefaultAction

' I split the database; now the backup code is not enough
' This will run the backup utility, based on the location of the db
Dim mylocation, stAppName As String

mylocation = DLookup("Path", "tbl_settings")

If Right(mylocation, 1) = "\" Then
stAppName = mylocation & "backup\backup.bat"
Else
stAppName = mylocation & "\backup\backup.bat"
End If

Call Shell(stAppName, 1)


End Sub


And, the backup utility is:

ECHO OFF

cls

echo .
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo Backup Utility
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo .
echo .
ECHO Copying Front End
copy "%~dp0..\CAT.mde" "%~dp0CAT.mde" /y
ECHO Copying Back End
copy "%~dp0..\CAT_BE.mdb" "%~dp0CAT_BE.mdb" /y
ECHO .
ECHO .
ECHO If it does not say "1 file(s) copied"
ECHO twice above, then the backup utility failed.
ECHO .
pause
 
V

Van T. Dinh

You're welcome ... Glad you worked it out ...

I haven't used acCmdBackup but I think it only backs up the current
database, i.e. onlt the Front-End in your case ....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top