Solved

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

Posted on 2004-08-04
4
163 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
ID: 11720109
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
ID: 11720261
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
ID: 11720443
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
ID: 11720791
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

789 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