Check this out. Maybe some one else can use this to help with one of their projects.
This is a fairly simple example. Would like to be able to do updates by field, but that is still beyond my capabilities right now. Still might be useful to some one.
After more data is entered, you can look up names by entering parts of the name at the top. You can also display all by entering an '*'.
You should also double click a line of data and right click on it to see what the program does.
Enjoy,
Bill
Thanks for the program and source Bill.
I use the dbBindParam for INSERT and UPDATE and find them easy to work with.
' UPDATE DATA into the Access Database
hDe = DBPREPARESQL(db,"UPDATE detail SET TheTime=?,Details=? WHERE id="+EditID)
DBBINDTIMEPARAM(hDe,1,TheDbTime)
DBBINDPARAMETER(hDe,2,TheDetails,100)
DBEXECUTE(hDe)
DBFREESQL(hDe)
hDe = NULL
In the above I picked out 2 fields I wanted to update in the 'detail' table.
Hope that might be of help with updating a field.
Allan
I explained my problem incorrectly. I understand the SQL and how to update individual fields. What I don't know how to do is to do a change in the ListView in a single line and column and know which exact field it is, so I can update only that field in the file. I know a listview can be defined to allow me to update a single field. Just don't know how to define it to allow me to do that and know that it was the one changed.
Bill
Not sure exactly what you are looking for but I think you want to know which column is clicked in the listview so that you can update that field??
The following code will show the Item or SubItem that is selected in the row.
You could use a SELECT statement to then get the name of the Field.
'Compile as a WINDOWS target
def d1:Dialog
'standard NMLISTVIEW
TYPE NMLISTVIEW
def hwndFrom:UINT
def idFrom:INT
def code:INT
def iItem:INT
def iSubItem:INT
def uNewState:UINT
def uOldState:UINT
def uChanged:UINT
def ptActionx:INT
def ptActiony:INT
def lParam:INT
ENDTYPE
CREATEDIALOG d1,0,0,315,168,0x80C80080,0,"List view test",&handler
CONTROL d1,@LISTVIEW,"",27,24,260,110,0x50000001,10
CONTROL d1,@STATIC,"TEST",27,140,240,20,0x50000000,20
DOMODAL d1
END
SUB handler
SELECT @MESSAGE
CASE @IDINITDIALOG
CENTERWINDOW d1
'insert columns and some items
'after an item is inserted we use @LVSETTEXT to
'change the subitems text
CONTROLCMD d1,10,@LVINSERTCOLUMN,0,"Column1"
CONTROLCMD d1,10,@LVINSERTCOLUMN,1,"Column2"
CONTROLCMD d1,10,@LVINSERTCOLUMN,2,"Column3"
CONTROLCMD d1,10,@LVINSERTCOLUMN,3,"Column4"
CONTROLCMD d1,10,@LVINSERTITEM,0,"Item 1"
CONTROLCMD d1,10,@LVSETTEXT,0,1,"Subitem 1"
CONTROLCMD d1,10,@LVSETTEXT,0,2,"Subitem 1"
CONTROLCMD d1,10,@LVSETTEXT,0,3,"Subitem 1"
CONTROLCMD d1,10,@LVINSERTITEM,1,"Item 2"
CONTROLCMD d1,10,@LVSETTEXT,1,1,"Subitem 2"
CONTROLCMD d1,10,@LVSETTEXT,1,2,"Subitem 3"
CONTROLCMD d1,10,@LVSETTEXT,1,3,"Subitem 4"
CONTROLCMD d1,10,@LVSETCOLWIDTH, 0, 60
CONTROLCMD d1,10,@LVSETCOLWIDTH, 1, 65
CONTROLCMD d1,10,@LVSETCOLWIDTH, 2, 65
CONTROLCMD d1,10,@LVSETCOLWIDTH, 3, 65
CASE @IDCONTROL
if(@CONTROLID = 10)
IF(@NOTIFYCODE = @NMCLICK)
SETCONTROLTEXT d1,20, "Selected: " + STR$(*<NMLISTVIEW>@LPARAM.iSubItem)
ENDIF
ENDIF
ENDSELECT
ENDSUB
Allan