Solved

Dirt Simple

Posted on 2000-03-20
11
228 Views
Last Modified: 2010-05-02
Hi,
I am going through the list of events for a datagrid and a data object trying to figure out which one is the best one to return a string value for a LastName column. I want the user the ability to click on a row, return the LastName  so the user can execute a search. Thank you.
diek
0
Comment
Question by:diek_nf
  • 4
  • 3
  • 2
  • +2
11 Comments
 
LVL 5

Expert Comment

by:Voodooman
ID: 2636993
'Set the column with the LastName in it
'*************************************

dbgGrid.col=6 'whatever column you want
lastname=dbgrid.text


Good Luck


Voodoman!
0
 
LVL 14

Expert Comment

by:wsh2
ID: 2637801
Voodooman:

diek nf writes: "I want the user the ability to click on a row, return the LastName so the user can execute a search"

How does your code snippet definitively answer diek nf's question?

<----- Code Begin ----->
Option Explicit
Private m_strSearch as String

Private Sub Command1_Click()

  If Len(m_strSeach) > 0 _
  Then
    Call SearchRoutine (m_strSearch)
  End If

End Sub

Private Sub DataGrid1_RowColChange(LastRow As Variant, ByVal LastCol As Integer)

  If DataGrid1.Col = LastNameColNumber _
  Then
    m_strSearch = DataGrid1.Text
  End If

End Sub

<----- Code End ----->


   

0
 

Author Comment

by:diek_nf
ID: 2638061
Voodoo,
I concur with wsh2 in part, this topic needs a little more than 3-4 lines. Don't get pissed because I rejected your answer, please expand a little more. Please note I am working so it can take a day for me to completely test everyones input.

diek
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 2

Expert Comment

by:Glen Richmond
ID: 2638217
you could try somthing like this which ive used to somthing similar on my own projects


Private Sub DataGrid1_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
     Dim y As Integer

    y = DataGrid1.Row
    If y = -1 Then Exit Sub
   
    DataGrid1.RowBookmark (y)
   
    ProductIDnumber = DataGrid1.Columns(0)
    Name = DataGrid1.Columns(3)

End Sub

Good Luck
0
 
LVL 3

Accepted Solution

by:
g_jones021500 earned 15 total points
ID: 2640390
Your datagrid is bound to the ADO data control right? This data control reflects user actions in the grid. If you need to know what lastname is in the current row of the datagrid just reference the field in the data control...

searchstring = ADODC1.recordset!lastname
0
 

Author Comment

by:diek_nf
ID: 2640925
g,
That was perfect. Thank you. I appreciate the help that everyone gave.
diek
0
 

Author Comment

by:diek_nf
ID: 2644630
glen, g, voodoo
If the above proves null it puts quite the wrench in my program. I have tried using an If conditon, to test if null then... do not continue
 else
searchstring = dat_Client.recordset!lastname
------------------------
This is driving me nuts. I am thinking it is a logic problem but.... I would appreciate any help


0
 
LVL 2

Expert Comment

by:Glen Richmond
ID: 2645505
if isnull(ADODC1.recordset!lastname ) then
    exit sub
else
    searchstring = ADODC1.recordset!lastname
end if



or.....

if ADODC1.recordset.eof then
    exit sub
else
    searchstring = ADODC1.recordset!lastname
end if

good luck
0
 
LVL 2

Expert Comment

by:Glen Richmond
ID: 2645546
the eof is if there is no records in the recordset...

you should test test for eof then a null in the field when using recordsets.

this should cover common problems when retriving data from recordsets.

<---------------------------->

if not ADODC1.recordset.eof then
   if not isnull(ADODC1.recordset!lastname ) then
      Searchstring =ADODC1.recordset!lastname
   else
      msgbox("No Value in Last Name")
   end if      
else
   msgbox("No Records")
end if

good luck
0
 
LVL 3

Expert Comment

by:g_jones021500
ID: 2645548
I would also check for Beginning of file (.bof)
0
 

Author Comment

by:diek_nf
ID: 2645706
Glen and g,
Between the 2 of you it works perfectly. I used your second comment glen and I have to play with bof g. Thank you so much. I truly appreciate your comments after I accepted g's answer.

diek
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

680 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