Trouble writting specific values to a table

  • Thread starter Thread starter BTU_needs_assistance_43
  • Start date Start date
B

BTU_needs_assistance_43

I'm having trouble writting values to a table in Access. I'm still new and
just haven't learned how to do it with the functions I'm using right now.
Specifically I want it to write a value without "a" at the end to the table
and as near as I can tell the rest of my funtions are working correctly. What
do I need to write in after the "=" sign or alter to get this to write the
string (vShots) or (vShots - a) to my table?

The table is Total Shot Names, the column of cells is Total Shot Name.

Dim vShots As Object

Set rst = dbs.OpenRecordset("Total Shot Names", dbOpenDynaset, dbAppendOnly)
' Selects Total Shot Names Table

Set vShots = xls.Range("B62") ' Selects a name if there is one

rst.AddNew

' If Then Else statement which defines values for Total Shot Names
If Right(B62, 1) = "a" Then
Left([vShots], Len(vShots) - 1) =
rst.Update
Else
Left([vShots], Len(vShots)) =
rst.Update
End If
 
When you are recordset processing, you refer to columns as:
rst.fields("column name").Value =
where rst is the variable you declared as recordset.
Also, to loop thru a recordset you use
do while not rst.eof
<your code>
rst.movenext
loop

hope this helps a bit.

-- Dorian
"Give someone a fish and they eat for a day; teach someone to fish and they
eat for a lifetime".


BTU_needs_assistance_43 said:
I'm having trouble writting values to a table in Access. I'm still new and
just haven't learned how to do it with the functions I'm using right now.
Specifically I want it to write a value without "a" at the end to the table
and as near as I can tell the rest of my funtions are working correctly. What
do I need to write in after the "=" sign or alter to get this to write the
string (vShots) or (vShots - a) to my table?

The table is Total Shot Names, the column of cells is Total Shot Name.

Dim vShots As Object

Set rst = dbs.OpenRecordset("Total Shot Names", dbOpenDynaset, dbAppendOnly)
' Selects Total Shot Names Table

Set vShots = xls.Range("B62") ' Selects a name if there is one

rst.AddNew

' If Then Else statement which defines values for Total Shot Names
If Right(B62, 1) = "a" Then
Left([vShots], Len(vShots) - 1) =
rst.Update
Else
Left([vShots], Len(vShots)) =
rst.Update
End If
 
I'm having trouble writting values to a table in Access. I'm still new and
just haven't learned how to do it with the functions I'm using right now.
Specifically I want it to write a value without "a" at the end to the table
and as near as I can tell the rest of my funtions are working correctly. What
do I need to write in after the "=" sign or alter to get this to write the
string (vShots) or (vShots - a) to my table?

The table is Total Shot Names, the column of cells is Total Shot Name.

Dim vShots As Object

Set rst = dbs.OpenRecordset("Total Shot Names", dbOpenDynaset, dbAppendOnly)
' Selects Total Shot Names Table

Set vShots = xls.Range("B62") ' Selects a name if there is one

rst.AddNew

' If Then Else statement which defines values for Total Shot Names
If Right(B62, 1) = "a" Then
Left([vShots], Len(vShots) - 1) =
rst.Update
Else
Left([vShots], Len(vShots)) =
rst.Update
End If

rst.Update is an ACTION that you execute after setting all the desired
recordset values - it's not a value itself. What field in Total Shot Names are
you trying to update? The syntax would be

Dim vShots As Variant
....
If Right(vShots, 1) = "a" Then
rs!fieldname = Left(vShots, Len(vShots) - 1
Else
rs!fieldname = vShots
End If
rs.Update
 
Back
Top