Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Dirt Simple

Posted on 2000-03-20
11
Medium Priority
?
231 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
[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
  • 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
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.

 
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 60 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

Industry Leaders: 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!

Question has a verified solution.

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

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…
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…
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 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

721 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