Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Change size of text fields on a form dynamically.

Posted on 2002-05-03
3
Medium Priority
?
191 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
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses
Course of the Month14 days, 5 hours left to enroll

581 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