Solved

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

Posted on 2004-08-04
4
164 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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

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…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

685 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