Solved

Dirt Simple

Posted on 2000-03-20
11
223 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
Comment Utility
'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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
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
g,
That was perfect. Thank you. I appreciate the help that everyone gave.
diek
0
 

Author Comment

by:diek_nf
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
I would also check for Beginning of file (.bof)
0
 

Author Comment

by:diek_nf
Comment Utility
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

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…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…

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

15 Experts available now in Live!

Get 1:1 Help Now