Solved

Open RecordSet at Specific Record

Posted on 2000-03-06
8
191 Views
Last Modified: 2012-05-04
VB Gurus,
I created a master/detail datagrid, using the dataform wizard. I want the recordset to open up at a specific record based upon the master's primary key "c_num", this value is generated and passed using a global variable("client_num") from frm_Client_Info to the Master/Detail Form, frm_All_Client_Info. Line 01 was generated by the wizard, the rest is my unsuccessful attempt to move to the specific record automatically with the form load. The code does not generate any errors it just does not work.

=====================================
Private Sub Form_Load()
(01)  Set grdDataGrid.DataSource = datPrimaryRS.Recordset("ChildCMD").UnderlyingValue

    Set db1 = OpenDatabase("C:\Database\Bacon.mdb")
    Set link = db1.OpenRecordset("Clients")

    link.MoveFirst
    Do Until link!c_num = client_num
        link.MoveNext
    Loop

    link.Close

End Sub
=====================================
Thank you.
0
Comment
Question by:diek_nf
  • 5
  • 2
8 Comments
 
LVL 10

Expert Comment

by:caraf_g
Comment Utility
Use SQL:

dim strSQL as string

strSQL = "select * from Clients where c_num >= " & cstr(client_num) & " order by c_num"

Set link = db1.OpenRecordSet(strSql)

0
 

Author Comment

by:diek_nf
Comment Utility
caraf_g,
I was praying that would work, but it did not. I think the code generated by the data wizard is circumventing any I add in. I welcome any more assistance and thank you for your help.

diek
0
 

Author Comment

by:diek_nf
Comment Utility
caraf_g,
Here is the code that was generated by the data wizard to open the current record.
-------------------------------------
Private Sub datPrimaryRS_MoveComplete(ByVal adReason As ADODB.EventReasonEnum, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
  'This will display the current record position for this recordset
  datPrimaryRS.Caption = "Record: " & CStr(datPrimaryRS.Recordset.AbsolutePosition)
End Sub
0
 
LVL 10

Expert Comment

by:caraf_g
Comment Utility
Yes, sorry... I never ever use data bound controls and I took it from that premise. I don't know how to solve the problem for those controls except to suggest you get rid of them and use normal controls. But I'm sure that's the last thing you want to hear right now...
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:diek_nf
Comment Utility
caraf
Thanks for trying.
diek
0
 

Author Comment

by:diek_nf
Comment Utility
caraf or any helpful programmer,
Please take a look at this:
This sql statement comes from a vb generated adodc component:

SHAPE {select BBINumber,First,Last from BBI} AS ParentCMD APPEND ({select Date_Interaction,InteractionAuthor,Note,Status from ClientInteraction Order by Date_Interaction } AS ChildCMD RELATE BBINumber TO BBINumber_Client) AS ChildCMD

I need to add this condition into the above SQL statement

WHERE BBINumber >= " & CStr(client_bbi_num) & "
0
 

Accepted Solution

by:
amarti earned 20 total points
Comment Utility
For syncronize Grid Detail to Master I use Event Reposition of Master Data, that fires when Master changes.  

In that Event, you can command the Detail Grid for changing with Master primary key if also the Details has it.

DataDetail.RecordSource = "SELECT .... FROM ... WHERE NameofDetailCampForClient_Num = " &  Client_Num


0
 

Author Comment

by:diek_nf
Comment Utility
amarti,
Sorry I didn't get back to you sooner. I've been up to my neck in work. Your solution proved helpful. Thanks.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now