Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there a way to use a variable in a recordset command?

Status
Not open for further replies.

adamrace

Programmer
Jan 16, 2007
14
GB
Hi,
I need a way of accessing a cell using the recordset command so for instance the code.

rs.Movefirst
While not rs.EOF
rs.[MYVARIABLE] = "True"
rs.Movenext
Wend

Or if there is no solution to this is there any other way that you could instantly fill all of the cells in a column through the click of a button for instance.

Thanks for any help
 
what is it that you are trying to do?

If you have a recordset, simply use the CopyFromRecordset method....

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
Sorry i was a bit vague,

I currently have it so that you enter a name in a text box, that then creates it as a field in a table using the append command. I would like it to do one of many different things all aiming for the same goal.
I want it to either, make the new field as a check box field, if you cant do that, create the field with the append with all of the cells containing "false" or finally which is what i was attempting to do, create the table and then using a recordset fill in each cell with a value, such as false. Here is my code, any further help will be immenseley appreciated.

Private Sub Command28_Click()
Dim dbsTables As Database
Set dbsTables = OpenDatabase("C:\marketing_database_new.mdb")
Dim tdftblONE As TableDef
Set tdftblONE = dbsTables.TableDefs!ContactInfo
NewOne = txtNewCatalogue
NewOneDelivered = NewOne + "_Delivered"

AppendDeleteField tdftblONE, "APPEND", _
NewOne, vbBoolean, 50
AppendDeleteField tdftblONE, "APPEND", _
NewOneDelivered, vbBoolean, 50
Debug.Print "Fields after Append"
Debug.Print , "Type", "Size", "Name"
dbsTables.Close
MsgBox "Patch Succeeded", vbOKOnly
End Sub

Sub AppendDeleteField(tdfTemp As TableDef, _
strCommand As String, strName As String, _
Optional varType, Optional varSize)
With tdfTemp
If .Updatable = False Then
MsgBox "TableDef not Updatable! " & _
"Unable to complete task."
Exit Sub
End If
If strCommand = "APPEND" Then
.Fields.Append .CreateField(strName, _
varType, varSize)
Else
If strCommand = "DELETE" Then .Fields.Delete _
strName
End If
End With

End Sub
 
If this is in MSAccess, you are better off posting here : Microsoft Access Modules (VBA Coding) forum705

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
You wanted something like this (DAO code)?
With rs
.MoveFirst
While Not .EOF
.Edit
.Fields(MYVARIABLE) = True
.Update
.MoveNext
Wend
End With

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top