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

"Pause" code while user enters data

Status
Not open for further replies.

air1jcw

Technical User
Jan 23, 2003
30
US
Below is an example of the code I am working with. This code changes the BackColor of lables on a form. This code works just, except I would like for it to "pause" while the user enters a small bit of data into 1 table/1 field. I have a query that deletes the previously entered data, and then the table opens to enter new data (just 1 field only). This is working just great up to this point.
I would like the user to be able to close the table (after the new data is entered), and then return back to the form, and the code would continue from there. I sure hope this makes sense!!

Private Sub Box321_Click()
Dim rstNewAllocations As New ADODB.Recordset
Dim ctl As Control
Dim i As Integer

DoCmd.OpenQuery "qryDeleteNewAllocations" 'Deletes previously entered GTWYs.
DoCmd.OpenTable "NewAllocations" 'Opens table to add new GTWYs

' Open a recordset based on the WWReviewhelper query.
rstNewAllocations.Open "qryNewAllocations", _
CurrentProject.Connection, adOpenKeyset, adLockOptimistic


' If no GTWYs overallocated.
If rstNewAllocations.RecordCount = 0 Then
MsgBox "There are NEW GTWYs selected to be allocated this part."
End If

If rstNewAllocations.EOF Then
Exit Sub

End If


'loop through form controls
For Each ctrl In Me.Controls

If TypeOf ctrl Is Label Then
With rstNewAllocations
.MoveFirst
For i = 1 To .RecordCount
If ctrl.Caption = !GTWY Then
ctrl.BackColor = 13434828

End If

.MoveNext
Next i
End With
End If
Next
End Sub
 
Well, here is another approach:

Do NOT enter data directly in the table
Create a form based on the table and replace the line:

DoCmd.OpenTable "NewAllocations" 'Opens table to add new GTWYs

with:

DoCmd.OpenForm "FormName", , , , acFormAdd, acDialog

This will pause your code until you close the form.
Again...NEVER enter data directly in tables!

HTH



[pipe]
Daniel Vlas
Systems Consultant

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top