You've posted the entire code sample given by Barry within your own sub, so that you have a sub within a sub, which is not allowed! When using code posted here, you have to remember a couple of things.
The names of fields, controls (textboxes, comboboxes, tables, etc) are frequently generic names. The members here usually don't know the exact name of your objects, and they frequently use boilerplate code that they have on hand to demonstrate how to solve a problem. You have to plug in the actual names of your own objects.
When someone posts an entire sub, such as
Private Sub ID_DblClick(Cancel As Integer)
'Code goes here
End Sub
you need to generate your own sub by way of your control's Properties Box, then copy and fill in the appropriate portion of the code (
the bold line in the above code) not including the Private Sub... and the End Sub parts. Answers may involve placing code in Subs commonly used for multiple purposes. If, for instance, code is offered that needs to be placed in the Private Sub Form_Load() and you already have code in this sub, you must
add the offered code to this sub in addition to the already existing code. You cannot simply add a second Sub Form_Load() sub.
This is the way your code should look:
- Private Sub ID_DblClick(Cancel As Integer)
-
DoCmd.OpenForm "NLFacturatie", acNormal, , "ID='" & ID & "'"
-
End Sub
-
Now as to the matter of posting code here. I know the example given in
Posting Guidelines for posting VB code is somewhat confusing. The problem is that if you actually show how the tags have to be done, the editor interprets that as actually being tags! Here's the drill:
Hi-lite the code in your post
At the top of the editor, Click on the
# icon .
This will place
[ Code ] and
[ /Code ]
tags around the code. For VB code you then have to go in and alter the first tag so that it looks like this
[ Code=vb ]
Note that
Code=vb has to be just like that, no spaces between the letters and the equal sign. Also note that the tags are shown above with spaces between the square brackets and the tag content.
When actually posting code there will be no spaces. To make sure you've got it right, try placing tags on your code, then click on
Preview Post at the bottom of the editor. Your code should appear like this:
-
Private Sub ID_DblClick(Cancel As Integer)
-
'Code goes here
-
End Sub
-
Good Luck and Welcome to TheScripts!
Linq
;0)>