Solved

Dirt Simple

Posted on 2000-03-20
11
226 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

785 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