Solved

Open RecordSet at Specific Record

Posted on 2000-03-06
8
197 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
[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
  • 5
  • 2
8 Comments
 
LVL 10

Expert Comment

by:caraf_g
ID: 2588259
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
ID: 2588411
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
ID: 2588513
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 10

Expert Comment

by:caraf_g
ID: 2588732
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
 

Author Comment

by:diek_nf
ID: 2588828
caraf
Thanks for trying.
diek
0
 

Author Comment

by:diek_nf
ID: 2589841
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
ID: 2591209
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
ID: 2597601
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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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 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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

724 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