Link to home
Start Free TrialLog in
Avatar of fbachri
fbachri

asked on

How to make Continuous form (like in access) with visual basic form.

Dear All,

I'm a VB newbie, is there any information or examples for making continuous form (like in access) with visual basic form...

Please Advise,
Fauzie
Avatar of anv
anv

hi !!

for creating a continous form in VB.. u need to create a control array for each control that u require to be repeated for every record...
say if we have 2 textboxes and two labels then
dim i!
i=0

set textboxes and labels index property to 0

while not rs.eof 'where rs is the recordset
if i <> 0 then
  Load text1(i)
  Load text2(i)
  Load Label1(i)
  Load Label2(i)

  text1(i).top = text1(i-1).top + 500
  text2(i).top  = text2(i-1).top + 500
  Label1(i).top = Label1(i-1).top + 500
  Label2(i).top = = Label2(i-1).top + 500

  text1(i).visible=true
  text2(i).visible=true
  Label1(i).visible=true
  Label2(i).visible=true

end if


  text1(i) = rs!Name
  text2(i) = rs!Age
  i=i+1
  rs.movenext
wend
Avatar of fbachri

ASKER

Dear anv,

Thanks for your advise, it works!...but i still confuse how to combine the form with a horisontal/vertical scrollbar so the form is scrollable.

please advise,
fauzie

Add an MDI Form to ur Application..

and set ur continous forms MDI Child property to true..

Avatar of fbachri

ASKER

Dear anv,

I have add an MDI form to my apps. and set my continuos form MDI Child property to true. but unfortunately i have an error message:

Compile Error:

Function or interface marked as restricted, or the function uses an Automation type not Supported in Visual Basic.


Below is the code in my continuous form :
------------------------------------------------
Private Sub Form_Load()
Dim con As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim i

Me.MDIChild = True                             '<------ set ur continous forms MDI Child property to true
With con
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
                    "Persist Security Info=False;Data Source=" & _
                    App.Path & "\db3.mdb"
.Open
End With
rs.Open "SELECT * FROM Table1", con, adOpenDynamic, , adCmdText

i = 0
While Not rs.EOF 'where rs is the recordset
If i <> 0 Then
  Load Text1(i)
  Load Text2(i)
  Load Text3(i)

  Text1(i).Top = Text1(i - 1).Top + 500
  Text2(i).Top = Text2(i - 1).Top + 500
  Text3(i).Top = Text2(i - 1).Top + 500

  Text1(i).Visible = True
  Text2(i).Visible = True
  Text3(i).Visible = True
End If
  Text1(i) = rs!tes1
  Text2(i) = rs!tes2
  Text3(i) = rs!tes3
  i = i + 1
  rs.MoveNext
Wend
End Sub


Please advise....
Fauzie




you cannot set

MDIChild property at run time this way..

set it True in design time..
Avatar of fbachri

ASKER

The continuous form MDI child property has set to true in the design time now. and now what should i write in the scrollbar Vscroll_Change() event to make it work?

Sorry my basic question. i hope you don't mind...

Regards,
Fauzie
r u using Scroll bars in the continous form or what??

u dont have to include any scroll bar object in ur continous form..

as now MDI will automatically add scroll bars to the form if size of continous form increases...  also set the continous form's windowstate to normal..at design time..

also for MDI set scrollbars to true..

Avatar of fbachri

ASKER

Yes i am using a scroll bar in the continuous form. but now i've delete it. but after following your instruction the mdi form still not display the scrollbar.

maybe you can check my apps. i will send the code to you but i need your email address. what i want is a continuous form just like in access. that it will display a scrollbar when the data show in the form are plenty enough.


Regards,
Fauzie
send me the code to

neeru.verma@drishinfo.com
Avatar of fbachri

ASKER

Dear anv,

i've send the code to you....

Thanks,
Fauzie
ASKER CERTIFIED SOLUTION
Avatar of anv
anv

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
Avatar of fbachri

ASKER

OK...thank you very much for your valuable information.


Regards,
Fauzie