|
-
Aug 15th, 2001, 01:26 PM
#1
Thread Starter
New Member
Allowing in cell editing in a Data-Bound Grid...
I am trying to allow users to make changes, and new rows etc to a data-bound grid displayed on a form. Does anyone have any experiance with this task? Below is the code I have so far:
_______________________________________________
Private Sub Form_Load()
Dim dbConnect As New clsDbConnect
Dim rsUsers As New ADODB.Recordset
Dim strSQL As String
' open the connection to the database
dbConnect.Connect
' define the SQL statement
strSQL = "SELECT UserName, UserPassword, UserLevelId FROM tblUsers ORDER BY UserName"
Set rsUsers.DataSource = dbConnect.ReturnRS(strSQL)
Set dtgUsersGrid.DataSource = rsUsers
With dtgUsersGrid
.AllowAddNew = True
.AllowDelete = True
.AllowUpdate = True
.AllowRowSizing = True
.RecordSelectors = True
End With
End Sub
___________________________________________
Thanks in advance!
-
Aug 15th, 2001, 09:13 PM
#2
Member
I've been there
Im just started working on databases and a few ways on how to add records, what iv done so far is this:
1. adding new records using another form with textboxes and
other controls.
2. adding new records on the main form where my datagrid is
displayed.
what i did on number 2 was, i put a command button on my form like "cmdAddOrCancel", one adodc control like "adcTables" and my bound datagrid like "grdTables"
Private Sub cmdAddOrCancel_Click()
If cmdAdd.Caption = "Add" Then
adcTables.Recordset.AddNew
grdTables.AllowUpdate = True
ElseIf cmdAdd.Caption = "Cancel" Then
adcTables.Recordset.CancelBatch adAffectCurrent
adcTables.Refresh
grdTables.AllowUpdate = False
End If
End Sub
i'v had difficulties using the .AllowAddNew property of the Datagrid so looked for another way. hope this helps you..
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|