Link to home
Start Free TrialLog in
Avatar of graysoc
graysocFlag for United States of America

asked on

DoCmd.GoToRecord acNewRec not working on subform

Hello all,

I have the following code:

    If Me.subform_other.Form.RecordsetClone.RecordCount = 0 Then
        Me.subform_other.SetFocus
        DoCmd.GoToRecord , , acNewRec
    End If

I get a run time error 2105, "You can't go to the specified record."  I think it is because I have the Allow Additions property set to NO for the subform.  I have that function disabled to prevent users from being able to add records on the subform by just rolling the mousewheel.

What is happening here is the main form has a record, but that record does not have an associated record in the subform, so when the form opens some of my code fails that tries to refer to the data on that subform.  The code works if there is a blank record there, so I just thought I would add a record if the system didn't find one on form_current.  

What I need is either:

1.  A way to add a record to the subform if one isn't present on form_current.

2.  A way to disable the mouse wheel functionality, so I can Allow Additions again.  I found very complicated ways of disabling the mouse wheel, so I just decided it was simpler to add a record.

Any suggestions?

Thanks,

G
ASKER CERTIFIED SOLUTION
Avatar of peter57r
peter57r
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of puppydogbuddy
puppydogbuddy

Try this
   If Me.subform_other.Form.RecordsetClone.RecordCount = 0 Then
        Me.subform_other.SetFocus
        Me.subform_other.AllowAdditions = True                     '<<<<<<<<<<<<<<<<
        DoCmd.GoToRecord , , acNewRec
    End If
see this link:

             http://support.microsoft.com/?kbid=278379
Avatar of graysoc

ASKER

Well,

The allowadditions = true didn't work.  (What I was going to do is allow additions for the one step, then set allow additions back to false.

Also, the MouseHook thing is NOT simple.  I've tried this site before.  Due to how our Access is networked or something, the mousehook.dll file just can't be found by Access.  At least, that is my estimation of why it doesn't work.  I get a "variable not defined" error when the mouse wheel disable code runs...  

Private Sub Form_Load()

Dim blRet As Boolean
blRet = MouseWheelOFF

End Sub

The variable that it is talking about is "MouseWheelOff" which tells me that MouseWheelOff is not getting what it needs from the dll, and Access thinks it is a variable.

Anyway, I'm working on this mousehook thing, to see if I can get it to work.

G
Avatar of graysoc

ASKER

Thanks Peter, I was able to get the mousehook to work.

G
I've used Lebans solution a few times.
I haven't run into a problem.
You have to have the dll in same folder as the front-end database that uses it.


Pete
Avatar of graysoc

ASKER

The problem was that I didn't have the module loaded that defined all of the variables.

G