D
Douglas J. Steele
Well, there's definitely no reason for Me.TxtPath: you can simply put the
path in a variable:
Dim Test2SQL As String
Dim strPath As String
strPath = Nz(DLookup("BackName", "tblBackPath", "BackID=1"), "")
If Len(Dir$(strPath)) > 1 Then
DoCmd.SetWarnings False
Test2SQL = "UPDATE table1 IN '" & strPath & "' " & _
"SET table1.IDName = '" & Forms!Form1!TxtInfo & "' " & _
"WHERE table1.IDNumber = 1 ;"
DoCmd.RunSQL (Test2SQL)
End If
What's your objection to the DLookup?
I suppose you could use CreateProperty to create a new database property and
store the path there, rather than in a table:
Sub SetBackendPath(strPath)
On Error GoTo Err_SetBackendPath
Dim dbCurr As DAO.Database
Dim prpBackend As DAO.Property
dbCurr = CurrentDb()
dbCurr.Properties("BackendPath") = strPath
End_SetBackendPath:
Set dbCurr = Nothing
Exit Sub
Err_SetBackendPath:
Select Case Err.Number
Case 3270 ' "Property Not Found"
Set prpBackend = dbCurr.CreateProperty( _
"BackendPath", dbText, strPath)
dbCurr.Properties.Append prpBackend
Resume Next
Case Else
MsgBox "Error " & Err.Number & ": " & _
Err.Description
Resume End_SetBackendPath
End Select
End Sub
You could then have a GetBackendPath function to retrieve that value:
Function GetBackendPath() As String
On Error GoTo Err_GetBackendPath
GetBackendPath = CurrentDb.Properties("BackendPath") = strPath
End_GetBackendPath:
Exit Function
Err_GetBackendPath:
Select Case Err.Number
Case 3270 ' "Property Not Found"
GetBackendPath = "Backend path property not created yet."
Case Else
MsgBox "Error " & Err.Number & ": " & _
Err.Description
End Select
Resume End_GetBackendPath
End Function
path in a variable:
Dim Test2SQL As String
Dim strPath As String
strPath = Nz(DLookup("BackName", "tblBackPath", "BackID=1"), "")
If Len(Dir$(strPath)) > 1 Then
DoCmd.SetWarnings False
Test2SQL = "UPDATE table1 IN '" & strPath & "' " & _
"SET table1.IDName = '" & Forms!Form1!TxtInfo & "' " & _
"WHERE table1.IDNumber = 1 ;"
DoCmd.RunSQL (Test2SQL)
End If
What's your objection to the DLookup?
I suppose you could use CreateProperty to create a new database property and
store the path there, rather than in a table:
Sub SetBackendPath(strPath)
On Error GoTo Err_SetBackendPath
Dim dbCurr As DAO.Database
Dim prpBackend As DAO.Property
dbCurr = CurrentDb()
dbCurr.Properties("BackendPath") = strPath
End_SetBackendPath:
Set dbCurr = Nothing
Exit Sub
Err_SetBackendPath:
Select Case Err.Number
Case 3270 ' "Property Not Found"
Set prpBackend = dbCurr.CreateProperty( _
"BackendPath", dbText, strPath)
dbCurr.Properties.Append prpBackend
Resume Next
Case Else
MsgBox "Error " & Err.Number & ": " & _
Err.Description
Resume End_SetBackendPath
End Select
End Sub
You could then have a GetBackendPath function to retrieve that value:
Function GetBackendPath() As String
On Error GoTo Err_GetBackendPath
GetBackendPath = CurrentDb.Properties("BackendPath") = strPath
End_GetBackendPath:
Exit Function
Err_GetBackendPath:
Select Case Err.Number
Case 3270 ' "Property Not Found"
GetBackendPath = "Backend path property not created yet."
Case Else
MsgBox "Error " & Err.Number & ": " & _
Err.Description
End Select
Resume End_GetBackendPath
End Function