?
Solved

Form automatically going into Edit mode right away

Posted on 2011-02-28
4
Medium Priority
?
350 Views
Last Modified: 2013-11-27
On my form, I have a UserName combo box that is the first field to receive the focus when the form opens.  The default value is set to "=UsersFormalName()" from the function below.

The problem is that the record goes right into Edit mode (the little pencil in the upper left corner) as soon as the form is opened or a "new" record is added.  Normally the mode would remain in "view" until user starts typing in a field (the little triangle in the upper left corner).

How can I stop the New record from going right into Edit mode but still have the UserName combo be the first field selected when the form is opened?  Ideally I would like the Edit to start when the user tabs away from the field or selects another name from the combo.

Public Function UsersFormalName()
     'DATABASE CONTAINS TABLE T_PEOPLE
     
On Error GoTo ErrorHandler_Err
     
     Dim db As Database
         Dim rst As DAO.Recordset
         Dim strSQL As String
         Set db = CurrentDb

strSQL = "SELECT tbl_People.PeopleName " & _
"FROM tbl_People " & _
"WHERE (((tbl_People.UserName)=fGetUserName()));"

      Set rst = db.OpenRecordset(strSQL)

      UsersFormalName = rst.Fields("PeopleName").Value 
     
Set rst = Nothing                   

'Error Handling-----------------
ErrorHandler_Err_Exit:
530      Exit Function
ErrorHandler_Err:
Select Case Err
Case 3059
Resume Next
'Case Else

'ErrorDetails = ErrorHandler(FormName:=FormNameConstant, ProcedureName:=ProcedureName, _
        ErrNumber:=Err.Number, ErrDescription:=Err.Description, ErrLine:=Erl)
End Select

End Function

Open in new window

0
Comment
Question by:SheaJeff
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 77

Accepted Solution

by:
peter57r earned 2000 total points
ID: 34998331
I don't think Edit mode is being produced by your default value function.
There must be something else going on.

How are you opening the form?  If in code can you post the code.
Is there any code/macro in the form Load or Form Current event procedures?
0
 

Author Comment

by:SheaJeff
ID: 34998528
I've added break/watch points to all of the form events, but still can't find what's causing it.
One thing that might help; if I have 2 or more records, and select the UserName field, then try to go to another record, the form goes right into Edit mode for the CURRENT record that I'm trying to move from.  If I select any other field, the form moves between records normally.

I do have this for the field, and it was working fine before I added the default value.
     Private Sub cmbo_UserName_GotFocus()
     Me.cmbo_UserName.Dropdown
     End Sub

On Enter and Exit events I use these functions to highlight the cell.  It's worked fine forever so I can't imagine it is interfering
     
Sub Highlight()
    With Me.ActiveControl
        .Properties("BackColor") = 9434879
     End With
End Sub
Sub Un_Highlight()
    Me.ActiveControl.Properties("BackColor") = 16777215
End Sub
0
 
LVL 75
ID: 34999190
As Peter eluded to ... if you have any code in the Form Current that sets a Control  Value, this will immediately make a record Dirty (ie in Edit mode).  Look for that.  Same would apply to the On Enter - On Got Focus event for a control first in the tab order, ... and you set a value .

mx
0
 

Author Comment

by:SheaJeff
ID: 34999775
Peter, you were right.
I had an additional line on the OnExit event of the combo box besides the UnHighlight.

'Me.cmb_AcctNumber.Value = AcctIDdefault
0

Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question