?
Solved

Change size of text fields on a form dynamically.

Posted on 2002-05-03
3
Medium Priority
?
188 Views
Last Modified: 2010-05-02
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"
0
Comment
Question by:jtrapat1
[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
3 Comments
 
LVL 18

Expert Comment

by:bobbit31
ID: 6989078
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?
0
 

Author Comment

by:jtrapat1
ID: 6989289
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
0
 
LVL 2

Accepted Solution

by:
ventond earned 400 total points
ID: 6989452
I suspect your code does something like:

sub grid_dblClick
frmMaintEdit.show
frmMaintedit.currentform="ApproBills"
end sub

vb does this:
Load frmMaintedit
frmMaintEdit_Load
Show frmMaintEdit
frmMaintEdit_Activate
frmmaintedit.currentform="ApproBills"

What you want vb to do is:
Load frmMaintedit
frmMaintEdit_Load
frmmaintedit.currentform="ApproBills" <---change
Show frmMaintEdit
frmMaintEdit_Activate

You need to change your code to:
Load frmMaintEdit
frmMaintedit.currentform="ApproBills"
frmMaintEdit.Show

This is a very common error. You can see the sequence if you single step through the code.

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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
Course of the Month14 days, 20 hours left to enroll

771 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