Full Version: curser in new record field
UtterAccess Forums > Microsoft® Access > Access Forms
deb
Access 2003
I have a main form called f001Project (PK ProjectID) and a sub form called f002Select2Dest (PK MOrder - Continuous form). On the main form I have a button that opens a popup form called f002Select1Source (PK MOrder - Continuous form). ) The form f002Select1Source is a form that contains data that can be dragged into the f002Select2dest Subform. The drag works great however...
o drag the data to the blank record area, I must first click on the blank MOrder field and then drag from the popup form f002Select1Source to the f002Select2dest Subform.
If I do not click the blank record area first the dragged record overrides the last record entered in the f002Select2dest Subform.
Any ideas on how to get the curser into the blank record area on the form!f001Project!f002Select2Dest.form before I drag the MOrder field in the POP up form (f002Select1Source) to the form!f001Project!f002Select2Dest.form. I need the curser to return to the blank record area on the form!f001Project!f002Select2Dest.form before each drag.
PLEASE HELP!! and Thank you in advance
f002Select1Source MOrder_MouseDown calls DragStart Me
f002Select1Source MOrder_MouseUp calls DragStop
f002Select2dest MOrder_MouseMove calls DropDetect
Code for drag mod is as follows...
Dim DragFrm As Form
Dim DragCtrl As Control
Dim DropTime
Const MAX_DROP_TIME = 0.1
Dim CurrentMode As Integer
Const NO_MODE = 0
Const DROP_MODE = 1
Const DRAG_MODE = 2
Sub DragStart(SourceFrm As Form)
' NOTE: You should not use Screen.ActiveForm in place of
' SourceFrm because you may be dragging from a subform.
Set DragFrm = SourceFrm
Set DragCtrl = Screen.ActiveControl
CurrentMode = DRAG_MODE
End Sub
Sub DragStop()
CurrentMode = DROP_MODE
DropTime = Timer
End Sub
Sub DropDetect(DropFrm As Form, DropCtrl As Control, _
Button As Integer, Shift As Integer, _
X As Single, Y As Single)

' If a drop hasn't happened, then exit.
If CurrentMode <> DROP_MODE Then Exit Sub
CurrentMode = NO_MODE
' The timer interval is permitted between the MouseUp event and
' the MouseMove event. This ensures that the MouseMove event does
' not invoke the Drop procedure unless it is the MouseMove event
' that Microsoft Access automatically fires for the Drop control
' following the MouseUp event of a drag control. Subsequent
' MouseMove events will fail the timer test and be ignored.
If Timer - DropTime > MAX_DROP_TIME Then Exit Sub
' Did we drag/drop onto ourselves?
If (DragCtrl.Name <> DropCtrl.Name) Or _
(DragFrm.hWnd <> DropFrm.hWnd) Then
' If not, then a successful drag/drop occurred.
DragDrop DragFrm, DragCtrl, DropFrm, DropCtrl, Button, Shift, X, Y

End If
End Sub
Sub DragDrop(DragFrm As Form, DragCtrl As Control, DropFrm As Form, DropCtrl As Control, _
Button As Integer, Shift As Integer, X As Single, Y As Single)
On Error Resume Next
DropCtrl = DragCtrl
If Err Then MsgBox Error$
End Sub
cwfitz
Maybe you can add a line of code up front on your Drag routine that will create a new record in the subform, then refocus to the desired field of the blank record????
deb
Tried so hard to out it in the forms that I didn't think to put it in the mod.
dded DoCmd.GoToRecord , , acNewRec to the DragDrop and it works just the way I needed. Thanks for pointing me in the right direction.
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.