Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic form with Access 2002 1

Status
Not open for further replies.

AlexRezid

Programmer
Jul 17, 2003
27
FR
Hi,

How can I manage a dynamic form with MS Access ?

I want the fields to be resized if the innertext is too big (I want the Overflow to be visible, and no scrollbar.

I tried the "Auto expand" parameter, but it doesn't work.

Any ID ?

Thanks

AlexRezid (alex-forums@ssji.net)
 
I dynamically expand fields by taking the length of the field and multiplying it by a number (which was found by trial and error) which, I then apply to the field's width property. Text box sizes don't seem to be measured by twips or pixels. Here's an example of my code.
Code:
Me.txtKeyLabel2.Width = (Len(rsKeyNames.Fields(1).Name)) * 150
Please note that this will only work in a .mdb file.
I'm not sure what you mean by "I want the overflow to be visible"?
 
Well, by "I want the overflow to be visible", I mean that I don't want scrollbar but I want the entire content to be visible at a time.

But thanks for your help. I'll try that right now, but I don't really see where you put that...

Let's try

Alex
 
Orion,

Could you explain your variables names please...

My textbox name is DMA, I wrote :
Code:
Me.DMA.Width = (Len(rsKeyNames.Fields(1).Name)) * 150
But I think I've something else to change, because it doesn't work...

SO, How do you find the (1) and what is rsKeyNames ?

Thanks for all
 
Sorry about that.
The form this is located on is a continuous form which is bound to a local table in Access. I use an ADODB recordset to find the maximum length for each column. I then use this recordset to adjust my fields accordingly. All of this is done from the OnLoad event.
Code:
dim strsql as string
dim rsKeySize as ADODB.recordset

strsql = "SELECT Max(Len(Field1)) AS Len1 FROM SortTemp_lkp"
Set rsKeySize = New ADODB.Recordset
rsKeySize.CursorLocation = adUseClient
rsKeySize.Open strsql, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
'I then use a large Case statement to determine how many columns the table has, within this I adjust the field sizes.
Me.txtKey1.Width = (rsKeySize.Fields("Len1") * 250)
I hope this makes sense. If you need any clarification on the code please just let me know.
 
Thanks Orion, but it doesn't work...

I put that in Sub Form_load

Code:
Private Sub Form_Load()
    Dim strsql As String
    Dim rsKeySize As ADODB.Recordset

    strsql = "SELECT Max(Len(DBR)) AS Len1 FROM InfosClients"
    Set rsKeySize = New ADODB.Recordset
    rsKeySize.CursorLocation = adUseClient
    rsKeySize.Open strsql, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
    Me.DBR.Width = (rsKeySize.Fields("Len1") * 250)

End Sub

where DBR is my field, InfosClient my table

If I make a mistake, tell me, and if you see another way for doing that, ask me too :p

----

OR, if you know a way to automaticaly select the Xth record in a web page with javascript, I'll do that with modifying the web page by hand .

Thanks

Alex
 
Sorry, It works

But it's not exactly what I wanted...
I want the form to be resized dynamically for each record, and not to be as big as the biggest record...

Is it possible ?
If yes, how have I to modify that ?

Thanks

Alex
 
So, Access is really dummy...

If you enlarge a fields, it doesnt put the next one go away...

So, I tried to make a Sub for going to the next record, It works in access form, but not in web pages.

It wrote this :
Code:
<SCRIPT language=vbs>
	Sub TestGo(Value As Integer)
        	Dim Record2 As New ADODB.Recordset
        	Dim i As Integer
        	Dim strsql As String
        
        	strsql = &quot;SELECT * FROM InfosClients&quot;
        	Record2.CursorLocation = adUseClient
        	Record2.Open strsql, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
        	Record2.MoveFirst
        	Do While Not Record2.EOF And Not i = Value
        	    Record2.MoveNext
        	    i = i + 1
        	Loop
        	Set Me.Recordset = Record2
	End Sub
</SCRIPT>
in the HEAD or my web page and :
Code:
<BODY style=&quot;OVERFLOW: auto&quot; vLink=#800080 link=#0000ff OnLoad=TestGo(2)>

And it says me there is an error in my page...

Could someone help ?

Alex
 
Thanks for all Orion

I've already a problem with your script in case of blank fields...

It tells me : rsKeysize.Fields(&quot;Len1&quot;) : Method or data Member not found

How can I avoid it ?

And for your help : a star :p

Alex
 
I'm afraid I can't help you here, I don't have any experience with using Access web pages. Sorry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top