473,563 Members | 2,668 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Opening a Form based on a cmboBox

6 New Member
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_Numb er". I want to choose one, select "Search" btn, and then have the "Topic_Informat ion" 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_SearchT opic_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_Numb er= '" & Me!cmbo_topicnu mber & "'"
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_Search Topic_Click:
Exit Sub

Err_btn_SearchT opic_Click:
MsgBox Err.Description
Resume Exit_btn_Search Topic_Click

End Sub
Jun 5 '06 #1
1 1343
wlc04
70 New Member
Private Sub btn_SearchTopic _Click()
On Error GoTo Err_btn_SearchT opic_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.OpenTabl e ("[Topic Information]")
DoCmd.OpenForm "Topic Information"
Forms![View All Topics].SetFocus
Forms![Topic Information].Visible = False


Set MyRS = Forms![Topic Information].RecordsetClone
Criteria = "Topic_Numb er= '" & Me!cmbo_topicnu mber & "'"
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_Search Topic_Click:
Exit Sub

Err_btn_SearchT opic_Click:
MsgBox Err.Description
Resume Exit_btn_Search Topic_Click

End Sub
Jun 12 '06 #2

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

Similar topics

14
11039
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 window.open function? I would prefer not to create a separate HTML page. So far all I have is the basic var cwin =...
3
4188
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 advance for any help... I have created a simple database that greets the user with user forms to make for user-friendly practicality. From these...
5
9856
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 Current event. I am using similar code to open each of the subforms successfully -- except for this one case which gives the above error. I have...
3
2011
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. Private Sub Form_Open(Cancel As Integer) If Len(Me.OpenArgs & "") > 0 Then Dim i As Integer Dim s As String
1
1651
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 off its own query. These queries are all based off the same table tblAnswers. The queries limit the questions for each form. So for example form 1...
3
1567
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 a report is the best method - yes? How do i get Access to view/print just the current record (or latest ID number) - at present it's always...
3
1494
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 have tried many ways but nothing is working. Any help will be greatly appreciated. Don't laugh too hard but my last try is as follows: Private...
2
1278
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 Command100_Click() If Not Me.NewRecord Then DoCmd.OpenForm "FrmPulls", , , "='" & Me!TEXT & "'" And "=#" & Me!DATE & "#", , acWindowNormal End...
2
4220
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 forms opening & closing. An example of this issue is as follows. I have a logon form open as the first thing. The main functional form opens when a...
0
7659
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7882
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8103
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6244
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5208
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3634
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3618
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1194
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
916
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.