On a main form I have a combo box which lists Account numbers. When a user types in a number which is not in the list, I use the Openform command to open a secondary form to enter the new data in the Account Number field, and then move to the next field (on the secondary form) for the user to start inputting further information. My code is as follows:<br><br> Dim ans As Integer<br><font color=green>'Clear the combo box</font><br> Me![AccountNumber] = Null<br> Response = 0<br><font color=green>'Display a message box for the user</font><br> ans = MsgBox("Account Number does not exist. " & _<br> "Do you want to add it to the list?", vbYesNo + vbExclamation, "Add a new Account?"
<br><font color=green>'If user clicks "Yes" then open the Tenancy form in Add mode</font><br> <b>If ans = vbYes Then<br> DoCmd.OpenForm "frmTenancy", acNormal, , , acFormAddNew</b> <font color=red>Problem Here I Think</font><br> Forms!frmTenancy![AccountNumber] = NewData<br> DoCmd.GoToControl "[Tenant]"<br><br>The problem is that the [Tenant] field will not hold the focus - the focus jumps to another textbox on the form.<br>This would be very confusing for my users (and is annoying me no end!).<br>The problem only occurs when I open the form in Add mode. If I open it in Edit mode, the focus stays where it should. This is what makes me think the problem is with the OpenForm AddNew line in my code.<br><br>Has anyone else had a problem like this, and can anyone suggest a solution?<br><br>Thanks in advance<br>Lightning<br>