F
Fred Boer
Hello:
I've been tinkering with some code that wouldn't run, and I need some help
because I don't think I understand something really fundamental about the
way Access saves data. I've been under the impression that once I exit a
bound control on a form, the data is immediately updated in the table. Is
this not correct? Here's what's happening: I have a form with a textbox.
Using the afterupdate event of the textbox, I run some code which pulls the
data from the field to which the textbox is bound. If I set a break point, I
can see, however, that the code isn't using the value I just entered, but
the previous value that existed in the table. Here's the code:
On Error GoTo ErrorHandler
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strAppTitle As String
Set db = CurrentDb()
Set rs = db.OpenRecordset("tblsettings")
strAppTitle = DLookup("Apptitle", "tblSettings")
' Change the application title. Pull application title from settings
table.
db.Properties!AppTitle = strAppTitle
' Update title bar on screen.
Application.RefreshTitleBar
db.Close
Set db = Nothing
Set rs = Nothing
ExitPoint:
Exit Sub
ErrorHandler:
fncErrorMessage Err.Number, Err.Description
Resume ExitPoint
SO.... I set the value in the textbox to "My Latest Online Catalogue1", with
existing value "My Latest Online Catalogue". On exiting the textbox, the
code runs. I check the value of "strAppTitle" - it is the older, unchanged
value. I'm perplexed!
Thanks!
Fred Boer
I've been tinkering with some code that wouldn't run, and I need some help
because I don't think I understand something really fundamental about the
way Access saves data. I've been under the impression that once I exit a
bound control on a form, the data is immediately updated in the table. Is
this not correct? Here's what's happening: I have a form with a textbox.
Using the afterupdate event of the textbox, I run some code which pulls the
data from the field to which the textbox is bound. If I set a break point, I
can see, however, that the code isn't using the value I just entered, but
the previous value that existed in the table. Here's the code:
On Error GoTo ErrorHandler
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strAppTitle As String
Set db = CurrentDb()
Set rs = db.OpenRecordset("tblsettings")
strAppTitle = DLookup("Apptitle", "tblSettings")
' Change the application title. Pull application title from settings
table.
db.Properties!AppTitle = strAppTitle
' Update title bar on screen.
Application.RefreshTitleBar
db.Close
Set db = Nothing
Set rs = Nothing
ExitPoint:
Exit Sub
ErrorHandler:
fncErrorMessage Err.Number, Err.Description
Resume ExitPoint
SO.... I set the value in the textbox to "My Latest Online Catalogue1", with
existing value "My Latest Online Catalogue". On exiting the textbox, the
code runs. I check the value of "strAppTitle" - it is the older, unchanged
value. I'm perplexed!
Thanks!
Fred Boer