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

Code that writes code

Status
Not open for further replies.

DOA

Instructor
Aug 16, 2001
29
US

Need a fix so I can have the code below write code

What happens:
ex. FormValue = "Me!ROW" & LoopTo8 & "Text1"
I would like the FormValue to equal Me!Row1Text1 update a record.
Then it loops and FormValue to equal Me!Row2Text1...

and to take it a step further with
rst!field1 = Me!Row1text1
then add +1
rst!field1 = Me!Row2text1
...


Any thoughs????




Private Sub RowUpdate()
Dim rst As Object: Set rst = CurrentDb.OpenRecordset("Row_Table")
Dim LoopTo18 As Variant
Dim FindID As Variant
Dim TableValue As Variant
Dim FormValue As Variant
Dim LoopValue As Variant

FindID = Me!QuoteID
LoopTo18 = 1
Do While LoopTo18 < 19
FormValue = &quot;Me!ROW&quot; & LoopTo18 & &quot;Text1&quot;
LoopValue = FormValue
If IsNull(LoopValue) Then
Else
rst.AddNew
FormValue = &quot;Me!ROW&quot; & LoopTo18 & &quot;Text1&quot;
TableValue = &quot;rst!Row&quot; & LoopTo18 & &quot;_Sku&quot;
TableValue = FormValue
FormValue = &quot;Me!ROW&quot; & LoopTo18 & &quot;Text2&quot;
TableValue = &quot;rst!Row&quot; & LoopTo18 & &quot;_Des&quot;
TableValue = FormValue

rst!Row_Number = LoopTo18 ' Row_Number
rst.Update

End If
LoopTo18 = LoopTo18 + 1
Loop


End Sub
 
Can anyone even help me on this?
 
At least ONE of us is confused. How about YOU?

THe ONLY possible result of this is the addition of a record to the table (&quot;Row_Table&quot;), with a single field (&quot;Row_Number&quot;) having a value. Most of the &quot;Code&quot; acomplishes NOTHING&quot;

FindId is declared and set - but never used in the remainder of the sub.

TableValue; FormValue; and LoopValue are Declared and set within the loop to form strings, and thus should be declared as String (NOT Variant!), or better yet just removed, since their values are never used to accomplish any (persistant) change.

&quot;TableValue&quot; is simply over-written four times within the loop;

&quot;FormValue&quot; is overwritten three times.

So, the real question is ... WHAT ARE you smoking?

(alternatively - a real explination of the intended result - which is NOT just to get a &quot;B&quot; or beter.

MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top