M
Michael
Calling process - all variables are dimensioned and have appropriate value
Const DB_PATH As String = "F:\ClientDocs\Programs\SaveFile.mdb"
Path = "F:\ClientDocs\ClientDocuments"
DT = CStr(Now())
' will always have value
OpenArgs = DT & ";" & DocName
' will have value if Client and Year known
If Nz(ClientId, "") <> "" Then
OpenArgs = OpenArgs & ";" & ClientId & ";" & CStr(TheYear)
End If
'On Error GoTo Err_Get_Client_Classify_Path
Set acApp = New Access.Application
With acApp
.OpenCurrentDatabase DB_PATH
.Visible = True
OldObs = .Forms.Count
.DoCmd.OpenForm "frmDocuments_Single", , , , , , OpenArgs
' pause calling routine logic
DoEvents
Do
NewObs = .Forms.Count
If NewObs <> OldObs Then
Else
' form is closed
Exit Do
End If
Loop
Set DataMdb = DBEngine.OpenDatabase(DB_PATH)
sSQL = "SELECT tblClientDocMaster.* FROM tblClientDocMaster " _
& "WHERE tblClientDocMaster.DocName = '" & DocName & "' " _
& "AND tblClientDocMaster.DT = '" & DT & "';"
Set rs = DataMdb.OpenRecordset(sSQL, dbOpenSnapshot)
If rs.RecordCount > 0 Then
ClientId = rs("ClientID")
TheYear = rs("Year")
Path = Path & "\" & ClientId & "\" & CStr(TheYear)
End If
rs.Close
Set rs = Nothing
DataMdb.Close
Set DataMdb = Nothing
End With ' I've
since failing on 2007, moved the nxt 3 statements up to just under Loop
'
This has no effect in 2003 - but I haven't tested it in 2007
acApp.Quit ' The failure
occurs well before this- in the loop
Set acApp = Nothing
The Open Form opened above sits in a separate mdb with just the called form.
It is a bound form and there is not any startup.
All variables are dimensioned
The form is bound to the table mentioned before and the record source is an
impossible for its keys.
The bound record is the right shape but empty.
Private Sub Form_Open(Cancel As Integer)
Dim dcy() As String, xx As String
xx = Nz(Me.OpenArgs, "")
If xx = "" Then
Cancel = True
Exit Sub
End If
dcy = Split(xx, ";")
sDateTimeVar = ""
dd = ""
cc = ""
yy = ""
If UBound(dcy) = 3 Then
yy = dcy(3)
cc = Nz(dcy(2), "")
End If
sDateTimeVar = dcy(0)
dd = dcy(1)
If Nz(dd, "") = "" Then
MsgBox "You have NOT Given a Name " & dd & " yet", 0, "Please Try
Again"
Cancel = True
Exit Sub
End If
' the table is 3 way-ed primary keyed ClientID Year and
DocName
If cc = "" Then
' ClientId = "" DocName = dd (passed via OpenArgs) Year =
9999
sSQL = "SELECT tblClientDocMaster.* FROM tblClientDocMaster " _
& "WHERE tblClientDocMaster.ClientID = '" & "" & "' AND
tblClientDocMaster.DocName = '" & dd & "' " _
& "AND tblClientDocMaster.Year = " & 9999 & ";"
' Access 2003 then finds (usually) a NEW record - waiting for its
ClientId to be entered, having its Year set to 9999 and its DocName set to
value of dd.
' The user enters appropriate ClientID, possibly changes Year -
DocName is protected and present - and Saves the record
Else
'All key values are supplied and other fields may be changed
sSQL = "SELECT tblClientDocMaster.* FROM tblClientDocMaster " _
& "WHERE tblClientDocMaster.ClientID = '" & cc & "' AND
tblClientDocMaster.DocName = '" & dd & "' " _
& "AND tblClientDocMaster.Year = " & CInt(yy) & ";"
End If
Me.RecordSource = sSQL
End Sub
This works in Access 2003, but in Access 2007 (the client's version), the
OpenArgs does NOT work and no values are passed across. Also, the Exit
button on the form
which Saves the new/updated record, does NOT click. Another peculiarity -
The form is both Popup and Modal with all Close etc buttons removed.
In 2003 this is a clear blue bar at the top - in 2007, there is a WORKING
x- Close box!
I've spent some time looking through groups about OpenArgs and have noticed
many posts about odd behaviour involving its non-function.
I'm stumped!!!
Michael
Const DB_PATH As String = "F:\ClientDocs\Programs\SaveFile.mdb"
Path = "F:\ClientDocs\ClientDocuments"
DT = CStr(Now())
' will always have value
OpenArgs = DT & ";" & DocName
' will have value if Client and Year known
If Nz(ClientId, "") <> "" Then
OpenArgs = OpenArgs & ";" & ClientId & ";" & CStr(TheYear)
End If
'On Error GoTo Err_Get_Client_Classify_Path
Set acApp = New Access.Application
With acApp
.OpenCurrentDatabase DB_PATH
.Visible = True
OldObs = .Forms.Count
.DoCmd.OpenForm "frmDocuments_Single", , , , , , OpenArgs
' pause calling routine logic
DoEvents
Do
NewObs = .Forms.Count
If NewObs <> OldObs Then
Else
' form is closed
Exit Do
End If
Loop
Set DataMdb = DBEngine.OpenDatabase(DB_PATH)
sSQL = "SELECT tblClientDocMaster.* FROM tblClientDocMaster " _
& "WHERE tblClientDocMaster.DocName = '" & DocName & "' " _
& "AND tblClientDocMaster.DT = '" & DT & "';"
Set rs = DataMdb.OpenRecordset(sSQL, dbOpenSnapshot)
If rs.RecordCount > 0 Then
ClientId = rs("ClientID")
TheYear = rs("Year")
Path = Path & "\" & ClientId & "\" & CStr(TheYear)
End If
rs.Close
Set rs = Nothing
DataMdb.Close
Set DataMdb = Nothing
End With ' I've
since failing on 2007, moved the nxt 3 statements up to just under Loop
'
This has no effect in 2003 - but I haven't tested it in 2007
acApp.Quit ' The failure
occurs well before this- in the loop
Set acApp = Nothing
The Open Form opened above sits in a separate mdb with just the called form.
It is a bound form and there is not any startup.
All variables are dimensioned
The form is bound to the table mentioned before and the record source is an
impossible for its keys.
The bound record is the right shape but empty.
Private Sub Form_Open(Cancel As Integer)
Dim dcy() As String, xx As String
xx = Nz(Me.OpenArgs, "")
If xx = "" Then
Cancel = True
Exit Sub
End If
dcy = Split(xx, ";")
sDateTimeVar = ""
dd = ""
cc = ""
yy = ""
If UBound(dcy) = 3 Then
yy = dcy(3)
cc = Nz(dcy(2), "")
End If
sDateTimeVar = dcy(0)
dd = dcy(1)
If Nz(dd, "") = "" Then
MsgBox "You have NOT Given a Name " & dd & " yet", 0, "Please Try
Again"
Cancel = True
Exit Sub
End If
' the table is 3 way-ed primary keyed ClientID Year and
DocName
If cc = "" Then
' ClientId = "" DocName = dd (passed via OpenArgs) Year =
9999
sSQL = "SELECT tblClientDocMaster.* FROM tblClientDocMaster " _
& "WHERE tblClientDocMaster.ClientID = '" & "" & "' AND
tblClientDocMaster.DocName = '" & dd & "' " _
& "AND tblClientDocMaster.Year = " & 9999 & ";"
' Access 2003 then finds (usually) a NEW record - waiting for its
ClientId to be entered, having its Year set to 9999 and its DocName set to
value of dd.
' The user enters appropriate ClientID, possibly changes Year -
DocName is protected and present - and Saves the record
Else
'All key values are supplied and other fields may be changed
sSQL = "SELECT tblClientDocMaster.* FROM tblClientDocMaster " _
& "WHERE tblClientDocMaster.ClientID = '" & cc & "' AND
tblClientDocMaster.DocName = '" & dd & "' " _
& "AND tblClientDocMaster.Year = " & CInt(yy) & ";"
End If
Me.RecordSource = sSQL
End Sub
This works in Access 2003, but in Access 2007 (the client's version), the
OpenArgs does NOT work and no values are passed across. Also, the Exit
button on the form
which Saves the new/updated record, does NOT click. Another peculiarity -
The form is both Popup and Modal with all Close etc buttons removed.
In 2003 this is a clear blue bar at the top - in 2007, there is a WORKING
x- Close box!
I've spent some time looking through groups about OpenArgs and have noticed
many posts about odd behaviour involving its non-function.
I'm stumped!!!
Michael