473,385 Members | 1,796 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Opening a form which goes directly to a particular record.

Hi!

Help would be highly appreciated!
I've got a form with clients which contains a subform with their orders in datasheet view. What I'd really like is to be able to open another form, which directly goes to the particular order details, for example by doublclicking the order id. I've know this is possible in forms view but is there any way of doing this while the subform is in datasheet view?

I've tried VBA and Macros but I just don't seem to be getting anywhere!

Thanks so much in advance!
Aug 7 '07 #1
5 1258
barry07
47
A double-click event should work whether the form is in datasheet mode or not. I've tested this code when the form is in 'continuous forms' and 'datasheet' mode

<CODE> VB
  1. Sub txtID_Dbl_Click
  2. DoCmd.OpenForm "Account_details", acNormal, , "ClientID='" & txtID &"'"
  3. End Sub

</CODE>

BTW- I'm assuming ClientID is a string, otherwise you can leave out the single quotes
Aug 7 '07 #2
Ok so I'm really new at this. This is what I have as an event procedure on my client ID Subform.


Private Sub ID_DblClick(Cancel As Integer)
Sub txtID_Dbl_Click()
DoCmd.OpenForm "NLFacturatie", acNormal, , "ID='" & txtID & "'"
End Sub
End Sub

As I'm guessing the first and last line of this code is what you meant with <Code> VB and <\Code> VB
(if I don't have those lines nothing happens at doubleclick.

However, now I keep getting the error message 'Expected End Sub'. I've opened 2 subs and closed them, so I really don't get my fault.
Aug 8 '07 #3
missinglinq
3,532 Expert 2GB
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:

Expand|Select|Wrap|Line Numbers
  1. Private Sub ID_DblClick(Cancel As Integer)
  2.  DoCmd.OpenForm "NLFacturatie", acNormal, , "ID='" & ID & "'"
  3. End Sub
  4.  
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:
Expand|Select|Wrap|Line Numbers
  1. Private Sub ID_DblClick(Cancel As Integer)
  2. 'Code goes here
  3. End Sub
  4.  
Good Luck and Welcome to TheScripts!

Linq ;0)>
Aug 8 '07 #4
Hi
thanx for the explanation cos I really wasn't sure about all that sub stuff. but i'm enjoying the challenge I must say!

Thanx for all the help!!!
Aug 8 '07 #5
missinglinq
3,532 Expert 2GB
Glad we could help!

Linq ;0)>
Aug 8 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Jeff Pritchard | last post by:
This is a twisted little problem. A client has an Access 2000 front-end using linked tables to a DNS to SQL Server 2000 back-end. With an Access 2000 back-end there is no problem. The problem...
1
by: Ian | last post by:
I want to open a form at a particular record, but I think I'm running into problems because the recordsource query is executing asynchronously. In the form's open event I use...
12
by: swingingming | last post by:
Hi, in the NorthWind sample database, when clicking on the next navigation button on the new order record with nothing on the subform (order details), we got an order with nothing ordered. How can...
7
by: Sam | last post by:
Hello All, We want our Call Service Representatives to be able to go back and view all the records in a table on a form. When closing and re-opening the form the form starts out as record 1 of 1...
2
by: nkoske | last post by:
I have a form with a subform in datasheet view and I have a event on one of the fields in the subform, so that the user can double click it and go to expanded information based on that field. ...
3
by: MartinR | last post by:
Hi, I'm still new to writing code in vba as I've only been introduced to access three weeks ago. I have written this code below and it executes but does not do what I want it to do. What I want is...
3
stonward
by: stonward | last post by:
Hi Guys, I have a main form, based on a query, with a subform based on another, that is used primarily for data input. The whole thing is my QUOTATION form. I want to print (view first) this, and...
4
by: Harlequin | last post by:
I have a question concerning the need to trigger events within a "child" subform which is itself enbedded within a master "parent" form and which is accessible via a tab in the parent form. Becuase...
4
by: limperger | last post by:
Hello everyone! Just in case anyone here has experienced this problem and knows how to deal with it: I have 2 forms from 2 related tables. We have more than 600 records in the first one and of...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.