syntax help on form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am having a time with this statement

Dim rs As ADODB.Recordse

'!!!force an add to get the list box to add value of field to the list box content
With r
.AddNe
.Field! "SYM" = [SYM] <----- arrgggghhh
.Updat
End Wit

Im looking to add a new record with the value of [SYM] on the form. The table field is also named "SYM"

Robert Good.
 
Hi Robert,
I assume you have other code in between your declare and what you posted.
The syntax to refer to a field in a recordset is:
rs!fieldName

or in your case because you are using the With syntax:
!SYM = Me.SYM

HTH
Dan Artuso, MVP

Robert Good said:
I am having a time with this statement.

Dim rs As ADODB.Recordset

'!!!force an add to get the list box to add value of field to the list box contents
With rs
.AddNew
.Field! "SYM" = [SYM] <----- arrgggghhhh
.Update
End With

Im looking to add a new record with the value of [SYM] on the form. The
table field is also named "SYM".
 
I've never used ADO, but I do know that in DAO you need to
set your database and recordset in the following manner: -

Dim dbs as Database,rst As RecordSet
Set dbs=CurrentDb
Set rst = dbs.OpenRecordSet ("Example",dbOpenDynaset)
With rst
.AddNew
.Field! "SYM" = [SYM] <----- arrgggghhhh
.Update
End With
Set rst=Nothing:Set dbs=nothing

NOTES

1. Declare the database you are working with with
the "Set dbs" Statement.
2. In the "Set rst" Statement, note that "Example" is the
Table Name.
3. Depending on the type of Table it is, you may also
need to set an additional option. E.g. if the Table is a
SQL ODBC Linked Table: -
Set rst = dbs.OpenRecordSet ("Example",dbOpenDynaset,
dbseechanges)
4. At the end of the Code, close the Connections.

HTH


Tony C.
-----Original Message-----
I am having a time with this statement.

Dim rs As ADODB.Recordset

'!!!force an add to get the list box to add value of field to the list box contents
With rs
.AddNew
.Field! "SYM" = [SYM] <----- arrgggghhhh
.Update
End With

Im looking to add a new record with the value of [SYM] on
the form. The table field is also named "SYM".
 
Try also:

.Fields("SYM") = Me.SYM

--
HTH
Van T. Dinh
MVP (Access)



Robert Good said:
I am having a time with this statement.

Dim rs As ADODB.Recordset

'!!!force an add to get the list box to add value of field to the list box contents
With rs
.AddNew
.Field! "SYM" = [SYM] <----- arrgggghhhh
.Update
End With

Im looking to add a new record with the value of [SYM] on the form. The
table field is also named "SYM".
 
That was a partial snip of the code

Thanks for all the help. I ended up using

With r
.AddNe
.Fields!SYM = Me.SY
.Updat
End Wit

The big gotcha was the .Fields instead of the .Field I was using

Thanks again
 
Back
Top