469,366 Members | 2,236 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,366 developers. It's quick & easy.

How to open form on specific record?

reginaldmerritt
201 100+
Hi,

I'm using the following code to open a form on a specific record. I have a form displaying records in a list which then allows users to click onto the record to open it up in a new form in a single view.

Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenForm "FRMBookingDetails", , "[BookingID] = " & Me.BookingID
  2.  
The form opens only on the first record only and never the chosen record. Sometimes it opens the form on a new record.

I'm guessing this has something to do with filtering but not sure what i should be checking for.

Thanks.
Feb 26 '11 #1
8 29957
munkee
374 256MB
I would be checking to ensure the form you are opening up has the field [BookingID] somewhere within its record.

Other than that it could be an issue with your form properties set wrong usually Allow Filter = false etc
Feb 27 '11 #2
reginaldmerritt
201 100+
Thanks munkee.

That was my first thought. But filter setting are set to true and i have the PK BookingID on the form.

I changed the code to the following and it seems to be working again now, not sure why.

Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenForm "FRMBookingDetails", acNormal, , "[BookingID] = " & Me.BookingID
  2.  
Feb 27 '11 #3
munkee
374 256MB
Weird. I wouldnt have expected adding the acnormal to change anything unless you have some properties set up within you form to only open in design view :| which once again I wouldnt expect.
Feb 28 '11 #4
TheSmileyCoder
2,321 Expert Mod 2GB
The acNormal is the default value, so I doubt that the change there is what fixed the problem.

I have noticed on occasion that if I have the form open in design view, and then switch to normal view, that I do not get the same behavior as if I had closed the form, and then reopened it.
Feb 28 '11 #5
reginaldmerritt
201 100+
That's a good point SmileyCoder. I've just noticed the same thing. Even if you make sure you save the changes sometimes there can be unexpected events if the form is not closed and then reopened.

I've only noticed this with DoCmd.OpenForm, but perhaps this effects other functions.

When ever i get any strange things happening i'm going to try this from now on.
Mar 9 '11 #6
Lysander
344 Expert 100+
I think you are missing a ' in your first example

You say
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenForm "FRMBookingDetails", , "[BookingID] = " & Me.BookingID
  2.  
Should it not be
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenForm "FRMBookingDetails", , ,"[BookingID] = " & Me.BookingID
  2.  
Mar 9 '11 #7
TheSmileyCoder
2,321 Expert Mod 2GB
I think Lysander has a good point, exept that he meant to type , and not '. In your second example where you included the acNormal, you had the correct amount of [,].
Mar 9 '11 #8
reginaldmerritt
201 100+
Sorry should have copied and pasted instead of writing it out. I do have the correct amount of commas in my code, but well spotted. Thanks SmileyCoder
Mar 9 '11 #9

Post your reply

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

Similar topics

reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.