Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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.
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…

867 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

20 Experts available now in Live!

Get 1:1 Help Now