borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (Open New Word Doc Via Access)Next Topic (Interface not Found - Error) New Topic New Poll Post Reply
AndreaVB Forum : VB General : Passing Font color from form to form
Poster Message
bolendercm
Level: Scholar


Registered: 25-10-2005
Posts: 39

icon Passing Font color from form to form



How can I pass font colors from one form to another.  I have a data input form with the field called Status.  If status = Open then the work order number = red.  When a technician goes to the program to find all open work order numbers how do I pass the font color from the input form to the BrowsePrintOrEdit Form.  The technician will only see the browsePrintOrEdit Form.  If the technician sees a WorkOrderNumber is red, that is his key to print the WorkOrder, fix the problem and close out the WorkOrder.  When he goes to the status field on the BrowsePrintOrEdit form he selects CLOSED and the WorkOrderNumber font is then re-colored to black.  I can change the font color, but how do I pass the open red color to the BrowsePrintOrEdit form.




____________________________
C.......................

08-12-2005 at 11:04 PM
View Profile Send Email to User Show All Posts | Quote Reply
newbie_1020
Level: Master


Registered: 29-11-2005
Posts: 117
icon Re: Passing Font color from form to form

use if else statement for coloring the workordernumber on form load event..example

private sub Form_load()

dim colorstatus as variable

'<use your db connection to retrieve the value of status in your DB, then maybe you can store in variable>

sql="SELECT fieldname (status) FROM tablename WHERE condition"

recordset=connection.open(sql)

status=recordset!status

if status= "OPEN" then

workordernumber.fontcolor<or whatever properties you set>=vbRED

end if

close connection


just make a better coding.hehehe@   

____________________________
united we stand,divided we stand alone...

09-12-2005 at 05:13 AM
View Profile Send Email to User Show All Posts | Quote Reply
bolendercm
Level: Scholar


Registered: 25-10-2005
Posts: 39
icon Re: Passing Font color from form to form



Could you be a little more specific??

____________________________
C.......................

12-12-2005 at 04:55 PM
View Profile Send Email to User Show All Posts | Quote Reply
JLRodgers
Level: Moderator

Registered: 04-04-2002
Posts: 1617
icon Re: Passing Font color from form to form

You wouldn't be passing the color itself, just comparing a value "open/closed" to that of what's in a database or wherever you have the records stored.

Since you have to be able to retrieve the records to display them on the form so that a tech sees the open/closed items, all you have to do is check at that point whether or not it's open or closed, and change the color at that time.





____________________________
Everywhere's Local (classifieds, job postings, & more for everycity in the world - user entered)

12-12-2005 at 09:00 PM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
bolendercm
Level: Scholar


Registered: 25-10-2005
Posts: 39
icon Re: Passing Font color from form to form


Let me try to be a little more specific.  Every Computer work request will have a number assigned to it.  The code below is used for a combo box at the top of the form.  This combo box contains all the computer work order numbers currently in the system.  When the user clicks on the down arrow he can then select the particular work order he is looking for.  What I wanted is all the work orders NOT closed out would show up in RED font rather than BLACK.

Private Sub cmbWorkOrderNumber_AfterUpdate()

    Dim rs As Object

    'Find the record which matches the control
    Set rs = Me.Recordset.Clone
    rs.FindFirst "[WORK ORDER Number] = " & Chr(34) & Me![cmbWorkOrderNumber] & Chr(34)
    Me.Bookmark = rs.Bookmark

End Sub

How do I get all the OPEN work order numbers to show up in RED font

      

____________________________
C.......................

19-12-2005 at 06:30 PM
View Profile Send Email to User Show All Posts | Quote Reply
steve_w
Level: Moderator


Registered: 18-04-2003
Posts: 1156
icon Re: Passing Font color from form to form

Hi

You say you have a status field on your Browse form, if its not "closed" when you load your data then set the font color to red on your work order field.

Steve  

19-12-2005 at 08:12 PM
View Profile Send Email to User Show All Posts | Quote Reply
bolendercm
Level: Scholar


Registered: 25-10-2005
Posts: 39
icon Re: Passing Font color from form to form



Steve,

Thanks for the reply.  What I ment to say was ".......I wanted is all the 'work order NUMBERS' to show up in RED font......" which correspond to a work order NOT Closed......

Sorry for the confusion....................

To think...........sometimes leads to confusion.................

    

____________________________
C.......................

19-12-2005 at 08:32 PM
View Profile Send Email to User Show All Posts | Quote Reply
JLRodgers
Level: Moderator

Registered: 04-04-2002
Posts: 1617
icon Re: Passing Font color from form to form

So are you saying that what you want is a combobox that has red font and black font in it?


Just thinking about it... that could make it difficult eventualy. Have 10-20 items, it'd be easy to view... 50, 60, where most are closed...

Offhand... if a tech's looking for open orders, I can't see a reason why they'd want to see the closed ones either. I'd have one form for open requests, and another for closed. Or, if you need them on the same form, have one combobox for closed another for open, or  just an option of "show closed" "show open" on the form, and re-load the combobox based on it's selection.

To have multi-color items in a combobox, will require subclassing I believe.


____________________________
Everywhere's Local (classifieds, job postings, & more for everycity in the world - user entered)

19-12-2005 at 09:09 PM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
bolendercm
Level: Scholar


Registered: 25-10-2005
Posts: 39
icon Re: Passing Font color from form to form



Steve,

I didn't even think of it that way.  Two heads ARE better than one.  The extra option for an "OPEN" form does make sense.  that seems to be the Quick solution.  However, my first option still is intriguing.

    

____________________________
C.......................

19-12-2005 at 09:30 PM
View Profile Send Email to User Show All Posts | Quote Reply
steve_w
Level: Moderator


Registered: 18-04-2003
Posts: 1156
icon Re: Passing Font color from form to form

Maybe you could use a different control to a combo box like a flex grid, with just the one column. You can then set the cell forecolor property.


Steve  

19-12-2005 at 11:03 PM
View Profile Send Email to User Show All Posts | Quote Reply
newbie_1020
Level: Master


Registered: 29-11-2005
Posts: 117
icon Re: Passing Font color from form to form

or,you could make two (2) comboboxes.one for opened,the other for closed.cheers steve!       

____________________________
united we stand,divided we stand alone...

20-12-2005 at 12:10 AM
View Profile Send Email to User Show All Posts | Quote Reply
bolendercm
Level: Scholar


Registered: 25-10-2005
Posts: 39
icon Re: Passing Font color from form to form



OK. Steve, now you've gone and done it................you have sparked my curiosity what is a FLEX Grid.  newbie,  In one of my previous post for this thread I showd the code that gets me all the WorkOrderNumbers to go into the combo Box.  What code can I use to differentiate the OPEN from the CLOSED Work Orders.  I know I can use the Status field as the piviot, however not quite sure how to code it..................      

____________________________
C.......................

20-12-2005 at 01:51 PM
View Profile Send Email to User Show All Posts | Quote Reply
steve_w
Level: Moderator


Registered: 18-04-2003
Posts: 1156
icon Re: Passing Font color from form to form

Okay, try this

Create a new project add a command button and an "Microsoft Flexgrid Control" get it from your components list. Off the "Project" menu heading.

Add the following code

Private Sub Form_Load()

    '====================================
    ' get your form the same size as mine
    '====================================
    Me.Height = 6500
    Me.Width = 5000
    
    With MSFlexGrid1
        .Top = 500
        .Left = 500
        .Width = 2000
        .Height = 5000
    End With
    
    With Command1
        .Top = 500
        .Left = 3000
        .Height = 500
        .Width = 1500

    End With
    
End Sub
Private Sub Command1_Click()

    With MSFlexGrid1
    
        '==============================================
        ' initial grid setup
        ' can also be done in the properties
        '==============================================
        .FixedCols = 0
        .Cols = 1
        .ColWidth(0) = .Width - 360
        .Rows = 1
        .FixedCols = 0
        .Col = 0
        
        '==============================================
        ' add heading
        '==============================================
        .TextMatrix(0, 0) = "Work Order"
        
        '==============================================
        ' add some dummy data
        '==============================================
        For i = 1 To 100
        
            .AddItem i
            
            '=======================================
            ' check to see if the number ends in a 5
            ' and set the cell color to red you would
            ' use your status check instead here
            '=======================================
            If Right(.TextMatrix(.Rows - 1, 0), 1) = "5" Then
            
                .Row = i
                
                '==============================================
                ' an example of the cell properties you can set
                '==============================================
                .CellForeColor = vbRed
                .CellBackColor = vbYellow
                .CellFontItalic = True
                .CellFontUnderline = True
                .CellFontBold = True
            
            End If
            
        Next

    End With

End Sub


Steve

20-12-2005 at 02:17 PM
View Profile Send Email to User Show All Posts | Quote Reply
newbie_1020
Level: Master


Registered: 29-11-2005
Posts: 117
icon Re: Passing Font color from form to form

alright, let's say for example we're going to load the OPEN and CLOSED data into two(2) separate comboboxes <cboredOPEN,cboblackCLOSED>...

we'll use this code:
dim cn new adodb.connection
dim rs as new adodb.recordset

'for the RED combo box <OPEN>
'if you want,you can count the recordsets first
set rs=cn.execute("SELECT COUNT(*) FROM table WHERE STATUS='OPEN'")

if rs(0)>0 then


   sql="SELECT * FROM table WHERE STATUS='OPEN'"

    set rs=cn.execute(sql)

    rs.movefirst
    do until rs.eof=true
      cboredOPEN.additem rs!WorkOrderNumber
      rs.movenext
      loop
else
   msgbox "all work orders have been carried out"
end if


'then it's the same for the cboblackCLOSED,just change the fields and the conditions and the control names...


'hope this helps..     

____________________________
united we stand,divided we stand alone...

21-12-2005 at 12:44 AM
View Profile Send Email to User Show All Posts | Quote Reply
bolendercm
Level: Scholar


Registered: 25-10-2005
Posts: 39
icon Re: Passing Font color from form to form



newbie,

Thanks for come back.  Hope you had good holiday !!!!
Tried your suggestion and at first wack.............didn't  work.
However, I do have one question, (well more than likely not one, but a bunch).  In one of my previous post I gave the code which I use to get the Work Order Numbers to my combo box.  Do I still use that code and inbed yours to break out the OPEN and CLOSED WorkOrderNumbers ??       

____________________________
C.......................

03-01-2006 at 02:48 PM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : VB General : Passing Font color from form to form
Previous Topic (Open New Word Doc Via Access)Next Topic (Interface not Found - Error) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder