C
Chris
I have and unbound form with an unbound List Box that has a query as the
record source. I use the following code to update the List Box and then
determine if there are records and take the apporpriate action.
Unfortunately, if I put the code
Forms![Post GASP Data].Controls("ListComputerID").ListIndex = 0
after the first "SetFocus" statement when no records exist, it errors out.
If I don't use this statement when records do exist, it just goes to the
first IF statement option and exits the function. How can I re-write this
code to look in the List Box for records and then take the appropriate action?
DoCmd.SetWarnings False
'This step imports new PC GASP Audit records into the
'the "GASP Audit - Server Details" table.
DoCmd.OpenQuery "Append - Computer Data"
'This call the referenced Function to update the Computer Data records
Call UpdateGASPAuditData
'This requeries the form and sets focus to the form.
Forms![Post GASP Data]![ListComputerID].Requery
Forms![Post GASP Data]![ListComputerID].SetFocus
'This checks for Nul record set and exits fucntion if true
If (IsNull(Forms![Post GASP Data]![ListComputerID])) Then
MsgBox "No New Computer Data to add to the GASP Database.",
vbInformation, "GASP Database"
Exit Function
Else
'This sets forcus to the first record
Forms![Post GASP Data].Controls("ListComputerID").ListIndex = 0
'This calls the referenced function to append the software records
Call AppendGASPComputerApplications
End If
MsgBox "The New Computer Data has been added to the GASP Database.",
vbInformation, "GASP Database"
DoCmd.SetWarnings True
record source. I use the following code to update the List Box and then
determine if there are records and take the apporpriate action.
Unfortunately, if I put the code
Forms![Post GASP Data].Controls("ListComputerID").ListIndex = 0
after the first "SetFocus" statement when no records exist, it errors out.
If I don't use this statement when records do exist, it just goes to the
first IF statement option and exits the function. How can I re-write this
code to look in the List Box for records and then take the appropriate action?
DoCmd.SetWarnings False
'This step imports new PC GASP Audit records into the
'the "GASP Audit - Server Details" table.
DoCmd.OpenQuery "Append - Computer Data"
'This call the referenced Function to update the Computer Data records
Call UpdateGASPAuditData
'This requeries the form and sets focus to the form.
Forms![Post GASP Data]![ListComputerID].Requery
Forms![Post GASP Data]![ListComputerID].SetFocus
'This checks for Nul record set and exits fucntion if true
If (IsNull(Forms![Post GASP Data]![ListComputerID])) Then
MsgBox "No New Computer Data to add to the GASP Database.",
vbInformation, "GASP Database"
Exit Function
Else
'This sets forcus to the first record
Forms![Post GASP Data].Controls("ListComputerID").ListIndex = 0
'This calls the referenced function to append the software records
Call AppendGASPComputerApplications
End If
MsgBox "The New Computer Data has been added to the GASP Database.",
vbInformation, "GASP Database"
DoCmd.SetWarnings True