Link to home
Start Free TrialLog in
Avatar of jtrapat1
jtrapat1

asked on

Change size of text fields on a form dynamically.

I'm using VB6 against an sql server 7 database.
I have a form with a datagrid on it;
when the user double-clicks on a certain record in the grid, it should bring up that record on another form in edit mode.
The edit form is working now.
---------------------------
However, I'm trying to add code where I can resize the input text fields based on the form that is brought up.
I have to do this because when I insert into the database, some fields are only 2 characters in length while some are 3 characters in length.
This throws my grid off for some reason.
Now when the user double-clicks on a record the record that is editable is the previous record that the user clicked on.
-----------
I do this thru a big select case statement and for some reason, this throws off the grid.
I do this in the form_activate routine but is there somewhere else I could put this code?
I tried it in the form_initialize event but that didn't work either.
Here's a code sample where I try to set the form properties:
Is there an alternative method to do what I want to do?
---------------------------------

Private Sub Form_Activate()
'setup form properties here

    Select Case CurrentForm
   
        Case "AppropBills"
            frmMaint.Caption = "Approp Bills " & CurrentYear
            txtFormName = "Approp Bills " & CurrentYear
            cmdInquirybyCode.Caption = "List Approp Bills by &Code"
            cmdInquirybySequence.Caption = "List Approp Bills by &Sequence"
            tblMaint = "AppropBills"
            frmMaintEdit.txtDescription.MaxLength = 80
            frmMaintEdit.txtCode.MaxLength = 3
           
        Case "FundTypes"
Avatar of bobbit31
bobbit31
Flag of United States of America image

if i understand you correctly:

1) user dbl clicks on a row in datagrid
2) opens a new form
3) you set text field maxlengths

what do you mean this throws off your grid?
Avatar of jtrapat1
jtrapat1

ASKER

I'll try to explain this better.
The grid is working fine now.
When I add in the code to change the maxlength property of the text fields here's what happens:
I double-click on a particular record but the record that is brought up is blank.
Then, I double-click again and the record that is brought up is the previous record that I clicked on.
So, it's like the grid is always one behind the record that I select.
The DataGrid isn't the Microsoft one; it's a third party control from Sheridan but works the same.
I thought it may have to do with how the grid is initialized but it's in a user control.
I don't see why the other properties can be changed on the fly but there's something it doesn't like about the maxlength property for text fields.


Thanks
ASKER CERTIFIED SOLUTION
Avatar of ventond
ventond
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial