Go Back   Access World Forums > Microsoft Access Discussion > Modules & VBA

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 02-02-2019, 06:14 AM   #1
helmerr
Newly Registered User
 
Join Date: Nov 2013
Posts: 140
Thanks: 33
Thanked 0 Times in 0 Posts
helmerr is on a distinguished road
Open record from combobox

I have a form "frmRequisitions" with unbound controls which is used for data entry.

I've placed a combobox in the form header which I would like to use to filter previously saved records from the "Description" record field, then open that previously saved record on the existing (opened) form.

How might I go about doing this? I've placed the following code in the combo box's After Update event. The form appears to refresh, but it doesn't bring up the selected record based on the Description field.


Code:
DoCmd.OpenForm FormName:="frmRequisitions", WhereCondition:="[Description]=" & Chr(34) & Me.cboBrowse & Chr(34)

helmerr is offline   Reply With Quote
Old 02-02-2019, 06:23 AM   #2
isladogs
High Noon Moderator
 
isladogs's Avatar
 
Join Date: Jan 2017
Location: Somerset, UK
Posts: 11,368
Thanks: 115
Thanked 3,111 Times in 2,829 Posts
isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold
Re: Open record from combobox

Description is a text field so needs text delimiters.
Use one of these

Code:
DoCmd.OpenForm "frmRequisitions",,,"Description='" & Me.cboBrowse & "'"
Or
Code:
DoCmd.OpenForm FormName:="frmRequisitions", WhereCondition:="[Description]='" & Me.cboBrowse & "'"
__________________
If this answer has helped, please click the Thanks button and/or click the 'reputation scales' symbol on the left.

Colin (Mendip Data Systems)
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


Website links:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


Common sense and a sense of humour are the same thing, moving at different speeds. (Clive James - RIP)
isladogs is offline   Reply With Quote
Old 02-02-2019, 06:32 AM   #3
helmerr
Newly Registered User
 
Join Date: Nov 2013
Posts: 140
Thanks: 33
Thanked 0 Times in 0 Posts
helmerr is on a distinguished road
Re: Open record from combobox

Thanks for your help. I tried both your codes but I'm unfortunately receiving the same results. It's a fairly simple database; I'm uploading it here if you have a chance to review the combobox/form.
Attached Files
File Type: zip FleetMaintenanceRequisition.zip (261.6 KB, 17 views)

helmerr is offline   Reply With Quote
Old 02-02-2019, 06:47 AM   #4
isladogs
High Noon Moderator
 
isladogs's Avatar
 
Join Date: Jan 2017
Location: Somerset, UK
Posts: 11,368
Thanks: 115
Thanked 3,111 Times in 2,829 Posts
isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold
Re: Open record from combobox

Whilst I'm sure I could fix it for you, there's a much better solution.
Unbound forms are almost always a bad idea.
You make unnecessary work for yourself having to write code that Access does automatically in bound forms

So change all your textbox controls from unbound to bound.
You can then get rid of almost all of your code and the form will filter correctly.
To add new records, you would then either open the form in data entry mode or click on New record button or use the navigation buttons at the top
__________________
If this answer has helped, please click the Thanks button and/or click the 'reputation scales' symbol on the left.

Colin (Mendip Data Systems)
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


Website links:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


Common sense and a sense of humour are the same thing, moving at different speeds. (Clive James - RIP)
isladogs is offline   Reply With Quote
The Following User Says Thank You to isladogs For This Useful Post:
helmerr (02-02-2019)
Old 02-02-2019, 07:17 AM   #5
helmerr
Newly Registered User
 
Join Date: Nov 2013
Posts: 140
Thanks: 33
Thanked 0 Times in 0 Posts
helmerr is on a distinguished road
Re: Open record from combobox

Lol - thanks, that fixed it. I originally took the unbound route because the last database I had to make was quite big and complicated.
helmerr is offline   Reply With Quote
Old 02-02-2019, 09:36 AM   #6
isladogs
High Noon Moderator
 
isladogs's Avatar
 
Join Date: Jan 2017
Location: Somerset, UK
Posts: 11,368
Thanks: 115
Thanked 3,111 Times in 2,829 Posts
isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold
Re: Open record from combobox

Glad you solved it.

__________________
If this answer has helped, please click the Thanks button and/or click the 'reputation scales' symbol on the left.

Colin (Mendip Data Systems)
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


Website links:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


Common sense and a sense of humour are the same thing, moving at different speeds. (Clive James - RIP)
isladogs is offline   Reply With Quote
Reply

Tags
combobox , form , vba

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Show one of many buttons based on combobox. Or open specific form based on combobox. jmkeuning Forms 6 09-08-2016 11:40 AM
Open report from combobox value with specific record bekward Reports 5 10-12-2014 10:18 PM
Open Form to New Record, ComboBox won't work johndohnal Forms 3 09-26-2013 01:41 PM
Using Combobox to locate and open a record in a differnt form RonnyD Forms 7 02-09-2008 04:24 PM




All times are GMT -8. The time now is 02:22 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World