Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Right Justificacion in textbox control conflicts with null values stored in recordsets.

Posted on 2003-11-10
4
Medium Priority
?
214 Views
Last Modified: 2010-05-01
I'm working with VB6 and SQL 7, with ADO. I have a form with a master table that allows the null value in some of the fields. And I have many TextBox controls to show thew info. Well, when I link the fields to the controls, I need the right justification to numbers, ok ? I do that as follows:

Set txtSpread.DataSource = rsAirplanes.DataSource
txtSpread.DataMember = rsAirplanes.DataMember
txtSpread.DataField = "Spread"
txtSpread.Alignment = vbRightJustify

And if I avoid the last line thew program runs with no problems, so how to do the justificacion but keeping the null values, of course ?

thank you very much for you atenttion.
0
Comment
Question by:pilotgabriel
[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
4 Comments
 
LVL 28

Expert Comment

by:vinnyd79
ID: 9716942
Have you tried:

If Not IsNull(txtSpread) Then txtSpread.Alignment = vbRightJustify
0
 

Author Comment

by:pilotgabriel
ID: 9717071
no, because I defines the linking of all the fields first of all, at the Form Load event, and then when the program retrieve the recordset I do this:

txtSpread.Text = IIf(IsNull(rsAirplanes.Fields("Spread").Value), "", rsAirplanes.Fields("Spread").Value)

It runs ok, but it is only to get the recordset. Then, at the moment of executing any move method becomes the error. Microsoft says that execution the instruction recordset.move 0 will solve that, by is lie, it gives the same error.
0
 
LVL 17

Accepted Solution

by:
inthedark earned 2000 total points
ID: 9717216
What happens if you set the Alignment first?
txtSpread.Alignment = vbRightJustify ' do first or at design time
Set txtSpread.DataSource = rsAirplanes.DataSource
' etc....

Another good affect for numeric data entry is to do something like this....so when you enter into a field the data moves to left left side of the box, but it depends how the operator wants it.

Private Sub Text1_GotFocus()
on error resume next
Text1.Alignment = vbLeftJustify
End Sub
Private Sub Text1_LostFocus()
on error resume next
Text1.Alignment = vbRightJustify
Text1 = Format(GitNum(Text1), "0.00")
End Sub

Public Function GitNum(RSField)

' Force a null item to be numeric

If IsNull(RSField) Then
    GitNum = 0
Else
    GitNum = RSField
End If

End Function
0
 

Author Comment

by:pilotgabriel
ID: 9717562
Ok, I did the first thing you said I runs perfect !
To show as an example, this way was wrong:

Set txtSpread.DataSource = rsAirplanes.DataSource
txtSpread.DataMember = rsAirplanes.DataMember
txtSpread.DataField = "Spread"
txtSpread.Alignment = vbRightJustify

but this way the program executes with no error:

txtSpread.Alignment = vbRightJustify
Set txtSpread.DataSource = rsAirplanes.DataSource
txtSpread.DataMember = rsAirplanes.DataMember
txtSpread.DataField = "Spread"

I don't no why, but the problem is solved, thank you very much ! I'll give the points of the answer.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

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…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
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…
Suggested Courses

705 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