Below is code I'm working with... Not sure if I'm doing this right... I need to be able create records based on the forms label captions and textbox names... If there are labels that are blue in font color, then that labels caption will be saved as a record, and if a text box equals any labels captions, then the textbox value will be saved in the same record with the label caption.... Sure hope this makes sense...!!!
There could be several labels that are blue in fontcolor - so I need to be able to save as a recordset - I suspect anyways.....
Any suggestions on how I can get this to work...??
Thanks in advance..!!
jw5107
Dim ctrl As Control
Dim db As Database, rsAllocHist As Recordset
Dim strAlloc, strGTWY As String
For Each ctrl In Me.Controls
If TypeOf ctrl Is Label Then
Select Case ctrl.ForeColor
Case Is = 16711680
strGTWY = ctrl.Caption
End Select
End If
Next
For Each ctrl In Me.Controls
If TypeOf ctrl Is TextBox Then
Select Case ctrl.Name
Case Is = strGTWY
strAlloc = ctrl.Value
End Select
End If
Next
Set db = CurrentDb
Set rsAllocHist = db.OpenRecordset("AllocationHistory", DB_OPEN_DYNASET)
rsAllocHist.AddNew
rsAllocHist("WWRNo") = Me!WWRNo
rsAllocHist("GTWY") = strGTWY
rsAllocHist("Allocation") = strAlloc
rsAllocHist.Update
rsAllocHist.Close
There could be several labels that are blue in fontcolor - so I need to be able to save as a recordset - I suspect anyways.....
Any suggestions on how I can get this to work...??
Thanks in advance..!!
jw5107
Dim ctrl As Control
Dim db As Database, rsAllocHist As Recordset
Dim strAlloc, strGTWY As String
For Each ctrl In Me.Controls
If TypeOf ctrl Is Label Then
Select Case ctrl.ForeColor
Case Is = 16711680
strGTWY = ctrl.Caption
End Select
End If
Next
For Each ctrl In Me.Controls
If TypeOf ctrl Is TextBox Then
Select Case ctrl.Name
Case Is = strGTWY
strAlloc = ctrl.Value
End Select
End If
Next
Set db = CurrentDb
Set rsAllocHist = db.OpenRecordset("AllocationHistory", DB_OPEN_DYNASET)
rsAllocHist.AddNew
rsAllocHist("WWRNo") = Me!WWRNo
rsAllocHist("GTWY") = strGTWY
rsAllocHist("Allocation") = strAlloc
rsAllocHist.Update
rsAllocHist.Close