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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

displaying VBA results in another table

Status
Not open for further replies.

747576

Programmer
Jun 18, 2002
97
GB
Hi,

Im writing some code which takes a number from a string and displays the number in the debug window. The program moves through each record of the current database at a time. Whats the code to put the results into a new table or update the existing table. I've tried the edit and update but get errors.
my code so far is:

' Declare variables.
Function CheckValue(strTableName As String, strColumn1 As String, strColumn2 As String)
Dim MyDB As Database
Dim rset As Recordset
Dim intI As Integer
Dim i As Integer
Dim SearchString, SearchChar, MyPos, MyPosNext, FirstWord
Dim qdf As QueryDef, strSQL As String


' Assign the current database to the database
' variable.

Set MyDB = CurrentDb
Set rset = MyDB.OpenRecordset(strTableName, dbOpenDynaset)


' move to start of list to force a count
rset.MoveFirst

' Loop through each record in the table
Do While Not rset.EOF

SearchString = rset(strColumn1) ' String to search in.
SearchChar = "/" ' Search for "/".
MyPos = InStr(1, SearchString, SearchChar) ' position of first slash mark
MyPosNext = InStr(MyPos + 1, SearchString, SearchChar) ' position of second slash mark

FirstWord = Mid(SearchString, MyPos + 1, (MyPosNext - MyPos) - 1) ' depth string


rset.MoveNext ' move to next record

Debug.Print FirstWord
MsgBox strTabName & " :" & CStr(FirstWord), vbInformation, "Values"

Loop ' end of loop

End Function


 
Try

rset.update
rset.edit

that updates fields in a table
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top