General information
Category:
Coding, syntax & commands
Title:
Selecting a specific record from a grid
Hi all,
I have a table which have a field with a unique number in it. This table is displayed in a grid on my form. Now if I click the first column (which contains the unique number) I want the form to close and let the program get the chosen record and show it in another form.
Until now that one is working, but now what if the user clicks on another column in that grid. I still want to get the record that was chosen. But the program always give me the first record in the table and not the chosen record. Can anybody help me with this strange problem?
Here's my code:
** In the Init of the form that contains the grid:
CLOSE DATABASES ALL
ThisForm.grdoverzicht.RecordSource = ''
INKEY(0.2)
WITH ThisForm.grdoverzicht
.ColumnCount = 9
.column1.header1.Caption = 'Lidnr.:'
.column2.header1.Caption = 'Branchenaam:'
.column3.header1.Caption = 'Branchenr.:'
.column4.header1.Caption = 'Bedrijfsnaam:'
.column5.header1.Caption = 'Contact persoon:'
.column6.header1.Caption = 'Adres:'
.column7.header1.Caption = 'Postcode:'
.column8.header1.Caption = 'Plaats:'
.column9.header1.Caption = 'Bank / Giro:'
.column1.Width = 100
.column2.Width = 150
.column3.Width = 75
.column4.Width = 245
.column5.Width = 250
.column6.Width = 200
.column7.Width = 100
.column8.Width = 150
.column9.Width = 150
ENDWITH
SET TALK OFF
CLOSE DATABASES ALL
SELECT 0
USE data\leden INDEX data\lidnr SHARED
SET SAFETY OFF
SELECT * FROM leden INTO TABLE temp2
SORT ON lidnr TO temp
SELECT 0
USE temp SHARED
GO TOP
ThisForm.grdoverzicht.RecordSource = 'temp'
ThisForm.grdoverzicht.Tag = ALLTRIM(STR(RECNO()))
ThisForm.grdoverzicht.Refresh
*****************************************************************
In the double click on the grid:
SET SAFETY OFF
SELECT temp
m_lidnr = ALLTRIM(ThisForm.grdoverzicht.Column1.Text1.Value)
SELECT leden
GO TOP
IF SEEK(m_lidnr)
m_branche = ALLTRIM(branche)
m_branchenrlid = ALLTRIM(branchenr)
m_bedrnmlid = ALLTRIM(bedrnm)
m_cplid = ALLTRIM(cp)
m_sexelid = sexe
m_adreslid = ALLTRIM(adres)
m_postcodelid = ALLTRIM(UPPER(postcode))
m_plaatslid = ALLTRIM(UPPER(plaats))
m_bankgiro = ALLTRIM(bankgiro)
thisform.release
close all
ENDIF
SET SAFETY ON
*********************************************************************
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only