VB6 & Database

I use DAO in VB6 to access my MDB files, I have many forms each has all buttons such as next, first, lase, prev, new...  etc to manipulate recordsets. I need to place these buttons on on toolbar in a MDI form so it controls all recordsets of every child form. As i am week in global module programming, i need someone to tell me how can i achieve this in simple steps so i can reduce my code to one instead of per the number of forms.

many thanks
abidsmlAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

paulstampCommented:
Do you want to have one single navigation control which controls all forms at once, or one that controls only the form that has the focus at the time ?
0
paulstampCommented:
If you want to control all at once, have an invisible data control on each data form and store a common value in the tag property of each form (ie "Data"). Then put navigation buttons on your MDI parent toolbar, and when the user clicks on them :

Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)

Dim fmrTemp as Form

For Each frmTemp in Forms
    If frmTemp.tag = "Data" then
        Select Case Button.Key
            Case "Next"
                frmTemp.Data1.Movenext
            Case "Last"
                frmTemp.Data1.MoveLast
        End Select
    Endif
Next frmTemp

End Sub



If you want to do one at a time, create a global variable frmFocus. When a child form is activated, set frmFocus = Me. This will keep track of the active child window. When the user clicks on a button on the toolbar do :

    Select Case Button.key
        case "Next"
            frmFocus.Data1.Movenext
   
         etc etc

Hope this answers your question


0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
abidsmlAuthor Commented:
thanks, it does work with data control, i do not use data controls, i use DAO here is the code to move next:
Private Sub cmdNext_Click()


    Rs1.MoveNext
    DisplayFields
        If Rs1.EOF Then    'Don't go past first record
            AllMessages (1)
            Rs1.MovePrevious
            DisplayFields
            NavEof
            Exit Sub
        End If
    DisplayFields
    Text1(1).SetFocus

End Sub

so is there a way that i can use Rs1.movenext instaesd of data1.recordset.movenext.

thanks for the help
0
paulstampCommented:
Thats a bit harder, because I doubt that all your forms have the same controls on them.

The best you can do is probably to have a standard public sub in each data form which is called by the toolbar_buttonclick event to fire off your routines, for example instead of frmFocus.Data1.Recordset.MoveNext have a single public routine "Navigate" which has a select case statement and depending upon the button clicked runs a routine like you described above.

For example :

Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)

    frmFocus.Navigate(button.key)

end Sub

===========

for each form

Public Sub Navigate(byval sKey as string)

select case sKey
    Case "next"
        Rs1.MoveNext
        DisplayFields
        If Rs1.EOF Then    'Don't go past first record
            AllMessages (1)
            Rs1.MovePrevious
            DisplayFields
            NavEof
            Exit Sub
         End If
         DisplayFields
         Text1(1).SetFocus
    Case "last"
   
    <etc etc>

Hope that helps.



0
Yogesh_kCommented:
define one recordset object per form with same name and u can easily get which form is active or having focus
with help of property
Screen.ActiveForm
get that form and put following code in tool click event for Move next tool button.

set frmCurrent = Screen.ActiveForm
frmCurrent.rstSameForAll.MoveNext

If any problem write to me at ytok@mailcity.com
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.