Hi Richard,
Your request is a little general, so I will give you an example how you
can programatically insert a record/row into a table in access. The
scenario is that you have a data entry form with a number of textboxes
where a data entry person can enter text, dates and numreric data.
Say you have a firstname field, lastname field, entrydate field, amount
field. After the textboxes are populated you can insert the row into a
table like this:
Private Sub button1_Click()
Dim strSql As String
strSql = "Insert Into tblX(firtsName, LastName, EntryDate, Amount) " _
& "Values('" & txtFirstName & "', '" & txtLastName & "', #" &
txtEntryDate & "#, " & txtAmount
DoCmd.RunSql strSql
End Sub
In Access you have to delimit text values in a sql string with single
quotes. You delimit date values with the # symbol. Numeric values
don't require any delimiters.
To delete a specific row you need to specify a Where clause in your sql
statement so that you only delete the desired row:
strSql = "Delete From tblX Where ID = " & txtID
DoCmd.RunSql strSql
This assumes that your table has an ID column (like an Autonumber
field). Or you could delete multiple rows like this:
strSql = "Delete from tblX Where FirstName = '" & txtFirstName & "'"
Say you want to remove all rows where firstname = 'Bill'. Note that I
don't use delimeters for the ID field since it is numeric (autonumber
field). But I have to delimit FirstName with single quotes since it is
a text field.
HTH,
Rich
*** Sent via Developersdex
http://www.developersdex.com ***