Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

VB6 & Database

Posted on 2000-02-19
5
Medium Priority
?
303 Views
Last Modified: 2010-05-02
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
0
Comment
Question by:abidsml
[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
5 Comments
 
LVL 3

Expert Comment

by:paulstamp
ID: 2537951
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
 
LVL 3

Accepted Solution

by:
paulstamp earned 170 total points
ID: 2537960
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
 

Author Comment

by:abidsml
ID: 2538238
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
 
LVL 3

Expert Comment

by:paulstamp
ID: 2538340
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
 

Expert Comment

by:Yogesh_k
ID: 2539842
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

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

650 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