Solved

How do I fix/suppress an Error Message When Changing Value In Bound Text Box

Posted on 2004-08-04
4
160 Views
Last Modified: 2010-05-02
An Error Message Appears when I change the text inside a textbox.  I have error handling arround this section of code, but the error message doesn't use my error handling, the message just appears.  The code (below) works like I want it to if the column being referenced is a normal column.  The error only occurs when the textbox is a Calculated Field.  After the error message VB does do my formatting.  I have tried using On Error Resume Next but the message still pops up.  I don't care how the message is fixed; either fixing the problem or forcing it not to appear.

BackGround:
If txtStateDate.Text <> "" Then
    txtStateDate.Text = Format(CDate(Format(txtStateDate.Text, "##/##/##")), "MMM DD, YYYY")
End If
If txtStateTime.Text <> "" Then
    txtStateTime.Text = DBTimeToReadableTime(txtStateTime.Text, False)
End If

DBTimeToReadableTime: Private Function That Formats Values (adds colons, converts to 12 hour, ...)

Both TextBoxes Are Bound To: A Recordset with properties of:   adLockReadOnly, adUseClient, m_rsRFA.CursorType

Calculated Field In SQL: 'fldApprovalDate & fldRejectDate as [fldBothDate]'
There will never be a situation where both fields are filled or both empty.
0
Comment
Question by:nebbles
  • 2
  • 2
4 Comments
 
LVL 1

Expert Comment

by:LastToKnow0
Comment Utility
When the textboxes are bound to the recordset, any modification to them attempts to modify the database itself.  You have the recordset set as read-only, so it is unable to update the recordset.  Because this is done behind the scenes, the usual error trapping misses is (I think).

I would reccommend not having the textboxes bound directly to the recordset, and instead updating their values through code.  This would prevent VB from trying to update the database automatically.
0
 

Author Comment

by:nebbles
Comment Utility
I'm not actually trying to update the values.  The text boxes are just for lookup.  
0
 
LVL 1

Accepted Solution

by:
LastToKnow0 earned 450 total points
Comment Utility
In any case, I think you need to disconnect the textboxes' datasource properties (I assume this is what you are using) from the recordset and do the lookups through code.
0
 

Author Comment

by:nebbles
Comment Utility
It does work when I do it that way, but when I reconnect the datasource the textbox gets the value again and clears the formatting.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now