Hello all.
I would like to ask if anyone knows how i can refresh my form without the focus being changed to the first record, essentially refreshing the form and subform while keeping my cirrent record as the active record.
I am entering data into a form, I have a command button that automatically numbers to the limit set by a text box in my current record( ie. txtbox=6 command button creates 6 new records in my subform numbered individually 1 through 6) I would like to see those records in the subform by adding the refresh command to the vba code i have written for the auto numbering so that when it is finished numbering, the forms refresh and bring me back to my current active record and i can see and manipulate the information in the newly created records.
Code follows:
Option Compare Database
Const KperBag = 1.7
Private Sub CmdCalcBuck_Click()
Dim totalK As Double
Dim Buckets As Double
totalK = (Val(Me.Units.Value) * KperBag)
Buckets = (totalK / Val(Me.txtKPerBucket.Value))
Me.lblBuckets.Caption = Buckets
On Error GoTo ConnectionError
‘save the record before querying it
DoCmd.RunCommand acCmdSaveRecord
Const sLen = 30, Loops = 5000
Dim trans As Variant
Dim quan As Variant
Dim strSQL As String
Dim BigString As String
quan = Buckets + 1
trans = txtDryId
BigString = txtKPerBucket
For joe = 1 To quan
Set myconn = CurrentProject.AccessConnection
strSQL = “insert into tblDryingLots values (” + Str(trans) + “,” + Str$(joe) + “, ” + Str(BigString) + “, null)”
Set rs = myconn.Execute(strSQL)
myconn.Close
Next
‘i would like to refresh here
Me.lblBuckets.Caption = “”
MsgBox “The values have been submitted. Thank you. You may now generate” & _
” the register codes, or continue to enter transfers.”
Exit Sub
ConnectionError:
MsgBox “There was an error connecting to the database, or entering the quantity” & _
” & values. ” & Chr(13) & Err.Number & “, ” & Err.Description
End Sub