B
Bill
In the OnOpen code below, execution is taking the Else
path even though I've verified that OpenArgs is Null, both
by displaying it via the MsgBox AND examining its value
when the runtime error is raised when the statement:
rsReplicate.Open tmpSQL, con, adOpenKeyset, adLockOptimistic
is encountered.
I feared that the mdb might be somehow corrupted, so I created
a new mdb and imported everything into the new mdb only to
discover that the erroneous path continues to be taken.
Have I been eating too many peanuts lately or what?
Bill
Private Sub Form_Open(Cancel As Integer)
DoCmd.Maximize 'Open window
maximized
Me.AllowAdditions = False
Me.AllowDeletions = True
Me.AllowEdits = True
Me.OrderByOn = False
CurMedia = "" 'Initialize current media
to nothing
ClearTheTimeRegister
VolID = -1 'Value of zero signifies volume table
update pending
MsgBox "[" & Me.OpenArgs & "]"
If Me.OpenArgs = Null Then 'Brand new entry pending?
'===========================================================================================
'YES, OpenArgs is Null if we have a new entry
CompID = 0 'Composer name is required
OrchID = 61 'None Specified
CondID = 79 'None Specified
GenreID = 0 'Genre is Required
SoloID = 49 'None Specified
LastPlayed = 0
Else
'===========================================================================================
'NO, OpenArgs is an ID of a Works to be replicated.
Set con = Application.CurrentProject.Connection
tmpSQL = "SELECT * FROM [Works] WHERE WorksID = " & Me.OpenArgs
Set rsReplicate = New ADODB.Recordset
rsReplicate.Open tmpSQL, con, adOpenKeyset, adLockOptimistic
WorksTitle = rsReplicate!Title
If Not IsNull(rsReplicate!Comments) Then
Comments = rsReplicate!Comments
Else
Comments = "" 'We allow Comments to be initialized
as zero-length
End If
If Not IsNull(rsReplicate!GAPuse) Then GAPDate = rsReplicate!GAPuse
Me.cmboGenre = DLookup("[SubGenre]", "QGenreFull", "[GenreID] = " &
rsReplicate!GenreID)
GenreID = cmboGenre.Column(0)
Me.cmboComposer = DLookup("[CompName]", "QComposers", "[CompID] = " &
rsReplicate!CompID)
CompID = Me.cmboComposer.Column(0)
Me.cmboOrchestra = DLookup("[Orchestra]", "QOrchestra", "[OrchID] = " &
rsReplicate!OrchID)
OrchID = Me.cmboOrchestra.Column(0)
Me.cmboConductor = DLookup("[CondName]", "QConductors", "[CondID] = " &
rsReplicate!CondID)
CondID = Me.cmboConductor.Column(0)
Me.cmboSoloist = DLookup("[SoloName]", "QSoloist", "[SoloID] = " &
rsReplicate!SoloID)
SoloID = Me.cmboSoloist.Column(0)
rsReplicate.Close
Set rsReplicate = Nothing
Set con = Nothing
End If
End Sub
path even though I've verified that OpenArgs is Null, both
by displaying it via the MsgBox AND examining its value
when the runtime error is raised when the statement:
rsReplicate.Open tmpSQL, con, adOpenKeyset, adLockOptimistic
is encountered.
I feared that the mdb might be somehow corrupted, so I created
a new mdb and imported everything into the new mdb only to
discover that the erroneous path continues to be taken.
Have I been eating too many peanuts lately or what?
Bill
Private Sub Form_Open(Cancel As Integer)
DoCmd.Maximize 'Open window
maximized
Me.AllowAdditions = False
Me.AllowDeletions = True
Me.AllowEdits = True
Me.OrderByOn = False
CurMedia = "" 'Initialize current media
to nothing
ClearTheTimeRegister
VolID = -1 'Value of zero signifies volume table
update pending
MsgBox "[" & Me.OpenArgs & "]"
If Me.OpenArgs = Null Then 'Brand new entry pending?
'===========================================================================================
'YES, OpenArgs is Null if we have a new entry
CompID = 0 'Composer name is required
OrchID = 61 'None Specified
CondID = 79 'None Specified
GenreID = 0 'Genre is Required
SoloID = 49 'None Specified
LastPlayed = 0
Else
'===========================================================================================
'NO, OpenArgs is an ID of a Works to be replicated.
Set con = Application.CurrentProject.Connection
tmpSQL = "SELECT * FROM [Works] WHERE WorksID = " & Me.OpenArgs
Set rsReplicate = New ADODB.Recordset
rsReplicate.Open tmpSQL, con, adOpenKeyset, adLockOptimistic
WorksTitle = rsReplicate!Title
If Not IsNull(rsReplicate!Comments) Then
Comments = rsReplicate!Comments
Else
Comments = "" 'We allow Comments to be initialized
as zero-length
End If
If Not IsNull(rsReplicate!GAPuse) Then GAPDate = rsReplicate!GAPuse
Me.cmboGenre = DLookup("[SubGenre]", "QGenreFull", "[GenreID] = " &
rsReplicate!GenreID)
GenreID = cmboGenre.Column(0)
Me.cmboComposer = DLookup("[CompName]", "QComposers", "[CompID] = " &
rsReplicate!CompID)
CompID = Me.cmboComposer.Column(0)
Me.cmboOrchestra = DLookup("[Orchestra]", "QOrchestra", "[OrchID] = " &
rsReplicate!OrchID)
OrchID = Me.cmboOrchestra.Column(0)
Me.cmboConductor = DLookup("[CondName]", "QConductors", "[CondID] = " &
rsReplicate!CondID)
CondID = Me.cmboConductor.Column(0)
Me.cmboSoloist = DLookup("[SoloName]", "QSoloist", "[SoloID] = " &
rsReplicate!SoloID)
SoloID = Me.cmboSoloist.Column(0)
rsReplicate.Close
Set rsReplicate = Nothing
Set con = Nothing
End If
End Sub