473,394 Members | 1,765 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,394 software developers and data experts.

Opening a Form based on a cmboBox

Hi, what I'm trying to do is probably very simple...but simple is relative! :D
I have a cmbo box on a form "[View All Topics]". It is populated with a query to show me all the Topics in my table where the primary key is "Topic_Number". I want to choose one, select "Search" btn, and then have the "Topic_Information" page display with it's results based on the Topic_Number. This is what I have in the "Search" button OnClick event. When it runs, the error is that it can not find the [Topic Information] form. It is not open yet, I know that is why. How can I open it (without it popping up) so that this code will find it? And is this code enough?


Private Sub btn_SearchTopic_Click()
On Error GoTo Err_btn_SearchTopic_Click
Dim Criteria As String
Dim MyRS As DAO.Recordset

' Find the record that matches the control
'load form2 to use its recordset, but don't show it
DoCmd.OpenTable ("[Topic Information]")


Set MyRS = Forms![Topic Information].RecordsetClone
Criteria = "Topic_Number= '" & Me!cmbo_topicnumber & "'"
MyRS.FindFirst Criteria

If Not MyRS.NoMatch Then
Forms![Topic Information].Bookmark = MyRS.Bookmark
End If

DoCmd.Close acForm, "[View All Topics]"

'show form 1 with the bookmarked record?
DoCmd.OpenForm [Topic Information]

Exit_btn_SearchTopic_Click:
Exit Sub

Err_btn_SearchTopic_Click:
MsgBox Err.Description
Resume Exit_btn_SearchTopic_Click

End Sub
Jun 5 '06 #1
1 1334
wlc04
70
Private Sub btn_SearchTopic_Click()
On Error GoTo Err_btn_SearchTopic_Click
Dim Criteria As String
Dim MyRS As DAO.Recordset

' Find the record that matches the control
'load form2 to use its recordset, but don't show it
'DoCmd.OpenTable ("[Topic Information]")
DoCmd.OpenForm "Topic Information"
Forms![View All Topics].SetFocus
Forms![Topic Information].Visible = False


Set MyRS = Forms![Topic Information].RecordsetClone
Criteria = "Topic_Number= '" & Me!cmbo_topicnumber & "'"
MyRS.FindFirst Criteria

If Not MyRS.NoMatch Then
Forms![Topic Information].Bookmark = MyRS.Bookmark
End If

DoCmd.Close acForm, "[View All Topics]"

'show form 1 with the bookmarked record?
DoCmd.OpenForm [Topic Information]

Exit_btn_SearchTopic_Click:
Exit Sub

Err_btn_SearchTopic_Click:
MsgBox Err.Description
Resume Exit_btn_SearchTopic_Click

End Sub
Jun 12 '06 #2

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

Similar topics

14
by: D. Alvarado | last post by:
Hello, I am trying to open a window containing an image and I would like the image to be flush against the window -- i.e. have no padding or border. Can I make this happen with a single call to a...
3
by: VanIkyn | last post by:
Hello peoples, This is a last resort, as I've run out of search strings I can think of for this problem. There may very well be a simple and logical solution that I have overlooked. Thanks in...
5
by: Lyn | last post by:
Hi, this has been driving me nuts. I'm on Office 2003 SP1, Win XP SP1. I am opening a form with a number of subforms based on various tables. The subforms are populated via the main form's...
3
by: Jim Evans | last post by:
Using code and suggestions from an earkier thread in this group, I have created the following cond for the open event of a form I am opening from the button click event of another form. ...
1
by: robertmeyer1 | last post by:
Hey, I am having a problem with opening some forms. I have several forms. The forms are based off the same table, tblClient. Each form has a sbf inserted into it. These sbf’s are each based...
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...
3
by: birt | last post by:
I have a form with two subforms on it. On my 2nd subform I want to open a new form base on three criteria. One is a string two are integer. It has been over six years since I have done this and I...
2
by: TADEL714 | last post by:
I am trying to open a form based on the record set of the current form. The form I am opening should filtered based on a text field and a date field. The code I am using is as follows: Private Sub...
2
by: =?Utf-8?B?RXRoYW4gU3RyYXVzcw==?= | last post by:
I am (still) relatively new to Windows applications, most of my experience has been Web based, and I am confused about what exactly happens when the Main() method is called and how to manipulate...
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.