Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2004-08-04
4
Medium Priority
?
168 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 1800 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

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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 Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…
Suggested Courses

596 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