Hide Table When Adding Record?

  • Thread starter Thread starter David Habercom
  • Start date Start date
D

David Habercom

I have two operations triggered from my main form which
add or change a record in a table. The table is the
datasource for a subform. When this happens, I get a very
distracting flash on the screen as the table pops up and
then disappears. I would like to hide this operation, but
I can't see how. Here is the code as it stands now:

Private Sub MchRaccRNo_AfterUpdate()
'If the R-Account number has been changed, update all
instances of it in FacTbl.
strNewRaccNo = Me.MchRaccRNo
If strOldRaccNo <> strNewRaccNo Then
DoCmd.SetWarnings False
DoCmd.OpenTable "FacTbl"
DoCmd.Minimize
DoCmd.SelectObject acTable, "FacTbl"
DoCmd.RunSQL "UPDATE FacTbl SET FacTblRNo='" &
strNewRaccNo & "' WHERE FacTblRNo='" & strOldRaccNo & "'"
DoCmd.Close acTable, "FacTbl"
DoCmd.SetWarnings True
strOldRaccNo = Me.MchRaccRNo
End If
End Sub

Thanks.
 
I have two operations triggered from my main form which
add or change a record in a table. The table is the
datasource for a subform. When this happens, I get a very
distracting flash on the screen as the table pops up and
then disappears. I would like to hide this operation, but
I can't see how. Here is the code as it stands now:

Private Sub MchRaccRNo_AfterUpdate()
'If the R-Account number has been changed, update all
instances of it in FacTbl.
strNewRaccNo = Me.MchRaccRNo
If strOldRaccNo <> strNewRaccNo Then
DoCmd.SetWarnings False
DoCmd.OpenTable "FacTbl"
DoCmd.Minimize
DoCmd.SelectObject acTable, "FacTbl"
DoCmd.RunSQL "UPDATE FacTbl SET FacTblRNo='" &
strNewRaccNo & "' WHERE FacTblRNo='" & strOldRaccNo & "'"
DoCmd.Close acTable, "FacTbl"
DoCmd.SetWarnings True
strOldRaccNo = Me.MchRaccRNo
End If
End Sub

Thanks.

Why are you opening the table at all? Just run the update action
query.

If strOldRaccNo <> strNewRaccNo Then
CurrentDb.Execute "UPDATE FacTbl SET FacTblRNo='" _
& strNewRaccNo & "' WHERE FacTblRNo='" & strOldRaccNo & "'"
End If

That should be all you need.

- Jim
 
Why are you opening the table at all? Just run the update action
query.

If strOldRaccNo <> strNewRaccNo Then
CurrentDb.Execute "UPDATE FacTbl SET FacTblRNo='" _
& strNewRaccNo & "' WHERE FacTblRNo='" & strOldRaccNo & "'"
End If

That should be all you need.

- Jim

I should have put DbFailOnError at the end of that ...

CurrentDb.Execute "UPDATE FacTbl SET FacTblRNo='" _
& strNewRaccNo & "' WHERE FacTblRNo='" & strOldRaccNo & "'" _
, DbFailOnError
 
Back
Top