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

jumping to next record in form ??

Status
Not open for further replies.

Dre313

Technical User
Jun 4, 2003
219
US
Hi,

I have a form which has unbound fields.. On my form .... I'll let the user enter in new data for a record.. click the add button.. my problem is.. after the user hits the add record button.. it does save all info to table.. but the original info that the user entered stays there.. I want it to go to the next record.. or blank the form out .. that way.. the user can enter in the second record..

I made the fields unbound in order to stop the user from scrolling records with the mouse wheel.. that was fine until I came to a problem with the numbering of my records..

I'm now using a function to call unique numbers and assigning them to each record.. but doing that made the mouse scroll again! So what I did was.. turn my "allow addition" event to No.. and that fixed the scrolling..

What my main concern is after the user enters in the new record and clicks "add" -- I would like for the form to blank out with the exception of my unique number function.. which is there to number my record.. I want that to jump to the next record ---which it does already but the form does not blank out.. whatever the user entered in last .. that what they see when they click add which I want to blank out...


sorry about the long post.. I just wanted to fill you in on what I did...


Thanks for any help
 
If I understand this correctly, all you need is a 'clearForm' sub to be called after you have saved the data to the database. In this sub set the values of the form controls you want to clear to "" or Null , or 0 or "No" depending upon what the control is and what the 'default' or cleared value is to be.

 
Dre,

To blank the form following the update, use Me.Requery.

This should refresh your form and clear the controls.

Hope this helps.



Leigh Moore
LJM Analysis Ltd
 
Hi all thanks for the response...

I tried adding Me.Refresh.. maybe I put it in the wrong place...

this is the code behind my add button..

Code:
Private Sub bSave_Click()
On Error GoTo Err_bSave_Click

    Select Case MsgBox("Do you want to save your changes to the current record?" & vbCrLf & vbLf & "  Yes:         Saves Changes" & vbCrLf & "  No:          Does NOT Save Changes" & vbCrLf & "  Cancel:    Reset (Undo) Changes" & vbCrLf, vbYesNoCancel + vbQuestion, "Save Current Record?")
        Case vbYes: 'Save the changes
            Dim RS As Recordset
            Set RS = CurrentDb.OpenRecordset("tblQR", dbOpenTable)
            With RS
                .AddNew
                !strProject = strProject.Value
                !strArea = strArea.Value
                !strReference = strReference.Value
                !Site = Site.Value
                !System = System.Value
                !EPO = EPO.Value
                !ControlNo = ControlNo.Value
                .Update
                .Close
                
            End With
            MsgBox "Record: " & ControlNo & " has been Added!", vbInformation, "New Project"

         GetID
         Me.Refresh

        Case vbNo: 'Do not save or undo
            'Do nothing

        Case vbCancel: 'Undo the changes
            DoCmd.RunCommand acCmdUndo
            Me.tbProperSave.Value = "No"

        Case Else: 'Default case to trap any errors
            'Do nothing

    End Select
    Me.Requery
Exit_bSave_Click:
    Exit Sub

Err_bSave_Click:
    If Err = 2046 Then 'The command or action Undo is not available now
        Exit Sub
    Else
        MsgBox Err.Number, Err.Description
        Resume Exit_bSave_Click
    End If

End Sub


thanks
 
jjob,

I have tested with what you said ..

Code:
Me.Field1=Null

this is what i did.. that did blank out the field..
but is there a way you can blank it out with one shot..
the way I did it.. NUlling out fields.. would you have to do that with each field.. ??
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top