Solved

Dirt Simple

Posted on 2000-03-20
11
224 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
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…

919 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

13 Experts available now in Live!

Get 1:1 Help Now