Open New Form Based On Main Form Primary Key (coding Issue?)
I am having trouble opening a new form with "child" data from my main form.
Basically I would press a button on my main form & want to open a new form listing the data based on a related key "txtFields(0)" from my main form
Here is my code on the "child" form - my main form button code is just "frmStudents.show"
Code:
Private Function initDatabase() As Boolean With SCGrid1 cn.Open Adodc1.ConnectionString rs.Open "select * from Transactions where account = '" & frmMain.txtFields(0) & "'", cn, adOpenKeyset, adLockOptimistic Set .DataSource = rs.DataSource End With On Error GoTo 0 initDatabase = True Exit Function End Function
I call the "initDatabase" sub in the form load event of the "child"
I get a datatype mismatch error
Each Child transaction has a unique key of TransactionID & a joined field of AccountID, which would align with txtFields(0) from the main form.
Much appreciated,
Vwalla
Edited by - vwalla on 11/18/2004 12:21:20 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
How To Open Another Form Within The Main Form
Hello everyone! Could anyone please tell me how I might call a about form within the main form? In my program I will have a menu and a about button in the menu and when the user clicks it, it will direct to the about form. Thanks !!
♣♣☻♫♦
Open Dialog And Not Click On Main Form?
OK I want a program to open up a dialog when I click a button. Then when the dialog is open I want it to be the only thing that can be used until it is closed. Like you know how if there is an error message on your computer you cant click anything in the background until you close the error message. Like that. I know how to make it open and all that just how can you get it to not allow the clicking and input anywhere but in the Dialog. Thanks in advance for any help on this topic.
How Can I Open Child Form To Dock In A Specific Position In The Main MDI From?
I’m trying to open up a child form in the right corner of my Program. Like in word xp it has the “New Document” side bar that can be docked into place or float. How do I do this? I would be happy with getting it to dock on the right side and not move all around, but if someone knows I might as well add that on…
Need Code To Refresh Or Close All Open Forms Except Main Form
My database often has many open forms based on a particular record chosen. Some forms usually remain open when a new record is accessed and remain focused on the previous record. I would like to either close all open forms except the main form when a new record is chosen or update all open forms to reflect the new record. Is this doable with VB code?
Open A Form Based On A Variable
Just wondering is it possible to open a form base on a variable. I know in Access you can.
I have 4 forms named frmAssemblerXXXX where X is a number.
The user will pick a number from a list box.
Is it possible to open the correct form based on the number the user picks without haveing to write a long if statment?
Open Form Based On Combo Box Selection
I’m going to lose it!
I have a form where the user to selects a state from a combo and then selects the county from the second combo (which is filtered so that the 2nd box lists only the appropriate county choices for the selected state.)
Now, this is what I would like to do next. After making the county selection, I want the user to click a button and I want access to open the form that is appropriate for that county. There are 3,600 or so counties and every county will have one of about a dozen types of forms assigned to it.
My tables:
Counties
-County_ID
-County
-State_ID
-Form_Type (This is the name of the appropriate form that belongs to the County)
States
-State_ID
-State
This is my code:
Dim Db As Database
Dim Rst As Recordset
Set Db = CurrentDb
Set Rst = Db.OpenRecordset("SELECT Counties.Form_Type FROM Counties WHERE" & _
" [County]= '" & Me.cboCounties & "'")
DoCmd.OpenForm Rst!Form_Type
When I click the button I get this error:
Run-time error ‘2498’: An expression you entered is the wrong data type for one of the arguments.
What am I doing wrong?
Open Query Based Form With Combo Box
Have a combo box to extract data from a table. I want to take the selected item from the Combo Box and use it for part fo a query that will open a form based on that query. Any ideas?
Open Form Based On Query Selection
I am building a database that lists participants who attend certain workshops. At the moment I am trying to build a form that lists all participants in a subform, and where you can add, edit, or delete participants from the main form. One feature I am trying to get to work at the moment is opening up a participants record by double clicking the name in the query subform. I have managed to get it to open up the correct form, where all of the participants detailed info is presented, but I can't get it to open up the right participant info. It will open up the form, but show the first record, wher I need it to show the record that corresponds to the name I clicked on.
Right now my code is simply DoCmd.OpenForm "formParticipants", , ,"......."
The dotted section represents the WHERE option. I have played with this several times and have n't gotten it to do what I want.
So basically, this is what I need it to do: Both the query and the form that I am trying to open by clicking on the query get their information from the participants table. Since the query has only basic info like first and last names, it is best suited for the main form. But I want to be able to click on one of those names and open up a more detailed form. The form is already made, and the participants table does have a primary key, which is just an autonumber. So I figured it wouldn't be that hard to get the form to recognize the selected primary key and display that record. I was mistaken.
Please help, thanks.
Jared
Make A Main Form Using MDI Form And Child Form
Hi there,
How can I create a child form that attached to the MDI form so that the MDI form and the child form looks like a single main MDI form in runtime ? I've tried to made it by disabling the min & max button of the child form and then load the child form in the MDI Form Load method, but with that way the child form can't be seen at the runtime.
Pls help me
Display Form But Keep Executing Code In Main Form (think I Need A Splash Screen ..)
I've got a form which i have calling up a progress form. this form just has a label adn a progress bar on it. however, after i call up the form to be visible, i need to be able to keep executing my code in the main form, and simply update the progress form's progress bar and label. I think i need a splash screen, can someone point me in the right direction?
Accessing Data From One Form From Main Form In Visual Basic 6
How do I extract data from a form into the main form for processing? For
instance, I have several image files in a form called images(images.frm),
indexed from 0 to 99, and I want to import these into a variable array in my
main form, main (form1.frm). How do I code a control to get these images
into an array in my main form from the images.frm?
TIA
How To VbNormal The Main Form After VbModal Form Closes?
I have a main form and a secondary form. The secondary for is a "psuedo-wizard" style for to allow the user to walk-through changing some program variables. It is called from the main for like this:
Code:
Main Form (frmMain) Calling Secondary Form (frmCustomCP)
Private Sub mnuCenterPoint_Click()
frmCustomCP.Enabled = True
frmCustomCP.Show vbModal
End Sub
I'm using the vbModal style because I don't want the user to be able to do anything else until they either finish the second form or close it. So, in the second form I've got a bunch of other things happening. When I close it, I have to set some variables back to 0 (these are global variables) and then close the second form and "re-open" the main form (preferably back to the same state (either "vbNormal" or "vbMaximized") as it was before the second form was launched.
Here's the code I'm using to do that:
Code:
Code for closing secondary form
Private Sub Form_Unload(Cancel As Integer)
intWizardLevel = 0
lngNewPointLat = 0
lngNewPointLng = 0
frmMain.WindowState = vbNormal
End Sub
This doesn't appear to be working. After the user "finishes" the wizard, there is an update to the database. After the update, I do a "Unload Me", and then, the closing code should take place (I believe). However, the form seems to load back to it's normal size, but then gets minimized again.
Any idea's on how I can make the frmMain return to it's previous size (and be displayed) when I close the frmCustomCP??
Thanks in advance for any help you can give.
DTFan
Show A Form Without Main Form Running Code
I'm trying to show a form (frmDriveSelect), but I don't want any code to run in the main form until the form I open (frmDriveSelect) closes. Any ideas? I tried "Show vbModal, frmDriveSelect" but that says form is already showing, which it isn't.
Want An Added Form To Be The Main One That Leads To The Existing Form?
Hi Vb Experts gain;
I have an existing application, I added to it a second form with many new controls on it, and I want this second form to be the first displayed form in design time then through one of its buttons it opens the existing form. is that possible? or shall I reverse the analogy of my design? and restart to design by order of priority first designed is first displayed...?????
Thank you
M C Benzerari
Display Information On Main Form That Is Gathered On Second Form.
Hello,
I am using a serial barcode reader to scan information into a label on a form that is NOT my main form. I would like to display this information on my main form as well. Actually, I am using the comm event from the scanner to capture the information so even if the second form is not open, I want to display the information on the main form (in a label). So...to hopefully simplify my question....How do I display information from one form to the main form.
Thanks!
How Do I Make My Sub Form Visible In Front Of The Main Form
The form.show command is not getting getting the form to be visible in front of the main form. How can I get it to be visible in front of the main form. I've tried form.show and form.visible. I've also tried making the main form main.hide and mainform.visible = Flase. This still does not work.
Pass Dataset From Main Form To Form With CR Viewer
What I am trying to do is this. I have the main form say form1 that uses ADO.NET. I run a query and pull back all the info to a dsReport dataset. Now I want to pass that dataset to another form called frmReport. This for has a CrystalReportViewer on it. I want to take the filled dataset from form1 and populate the CR Report on frmReport.
Dim crReport As rptReport
crReport = New rptReport
crReport.SetDataSource(dsReport)
CrystalReportViewer1.ReportSource = crReport
Text Of Other Form Appears Sometimes On My Main Form After Resizing
hello, i finally got my resizing code working and with that, i encountered a strange thing
When resizing my main form, sometimes the name property of one or two textboxes of another form appears. This form however isn't loaded. The text doesn't also always appears! I have attached a screenshot to visualize my problem (see red ellips).
Someone knows why this happens? If you need more info, let me know.
Thanks
Problems Showing The Main Form In Sub Main()
Hi,
My application use a Sub Main() to loadup a slash screen, while I do some initialising work, and then loads up the main form with frmMain.show.
The frmMain has lots of controls on it, some 3rd party, and also 2 userControls of my own.
One of my users has reported, that once the splash screen has been displayed, the app then just 'hangs' before frmMain is displayed. However, this works fine on many many other PCs.
I have lots of tracing in my app, and I can see that all the init stuff works, and it gets to the bit before it does the frmMain.show, but it never gets to the frmMaim_Load() event.
I have some tracing in the UserControls, and I see that both of these execute the Initialize, ReadProperties and ReSize events, but thats it.
I presume, that there is something wrong with one of the other 3rd party controls I'm using, and for some reason they are 'failing' in some way.
Does any one know of any tracing for other was to figure out what is going on between me issuing the .Show command, and the Load() event firing?
Thanks for you help,
Rob Donovan.
ProIV Resource Centre <a href='http://www.proivrc.com'>www.proivrc.com</a>
Call Main Form Sub From VbModal Form
I'm currently converting my Access Project to a vb6 project. I have 2 forms. The Main Form (frmMain) opens the 2nd Form (frmComm) upon clicking a button (vbModal). I would like to call a subroutine on the Main Form from the 2nd Form (frmComm), as the Main Form has a MSComm control that is used for receiving and sending data. In Access, I could just Call the Subroutine as follows:
Call Parent.cSendToBoard
How do I accomplish this in VB6 code?
Display Form Ontop Of Main Form
Hello Everybody!
I am trying to do the following: When a user clicks on a button, a form pops up with some buttons on it. The problem I am having, is when that new form appears, I don't want the user to be able to click on or access the Main form until they click a button on the new form. I guess this would be like writing a MSGBOX. The user needs to click something on that message box before they can do anything on the main form again. How can I accomplish this with a form?
Thanks for your help!
~ Mark
Child Form Without Main Form Flickering
I want to show a form as a child of another form (NOT A MDI APP).
I use the SetParent. It works well but the main form title bar flickers because the time i load the form and the call of SetParent the mainform lost the focus and the color of the title bar changes and makes some flicker effect.
Could you help ?
thanks
Flexgrid Form Result Based On Login Form
I have a login form and I have a main form which contains a flexgrid....
I would like to do something like that when a user login the main form shows in the flexgrid only the result for that user.
Also I have a third form called ''frmtxt2db" which is having the db connection in the form I would like to put the connection and db propeties inside the module which is being used by the login form and main form. ( As I have done 'frmtxt2db' form seperately before I create the other three forms and I added the form then to the project)
My code is attached I hope somebody can help me with it.
Thanks again.
Changing Form Recordset Based On Selection On Another Form
Good afternoon,
Im not sure what is the problem here, but here is the issue:
i have a main form that contains 3 subforms, i would like when i select a record on the first form, to get details related to it on the second one. the first form contains names of people, the second one contains transactions related to those people. the data of each form comes from a different table.
i have coded an event "on current" on the first form that captures the name of the person. and then i re-set the record source of the second form. but its not working.
here is the code i have on the on current event:
Code:
GlobalVariables.initID = Me.ID.value
Form_ps_Strategysubform.Filter = "InitiatorID ='" & GlobalVariables.initID & "'"
Form_ps_Strategysubform.FilterOn = True
Form_ps_Strategysubform.Requery
Second Form Centered In Main Form?
I never thought about this until today, how do I get a second for to be centered in the main form?
For example, I have a form and when i press a button a second form opens over the top of the first form but its smaller so you can still see the edges of the first form.
I have everything set to center but if i move the first form to the edge of the screen and click the button the second form opens in the middle of the screen and not in the middle of the first form.
How is this done?
PixieDust.
A Form Which Should Apper For Few Second Before The Main Form
Hi again,
I dont know how should i call it, flash form or........
In my project i have put the form, which supposed to appear when i run it which should last for at least 30sec,like when you open a word document, and then the main form should appear.
But when i debug that form apper and it doesnt call the other form. How can i do it.
Thanks.
JPG On A MDI MAIN FORM
Hi. I have a MDI Appliction. I want to display a Picture on the Main MDI form, but i can't get it to work. Is there a way of doing this.?
Main Form
i have a program with many forms in it and everytime i click to go to a new form, the old form is still there. the new form comes up and is active but i don't want the first form to be showing. is this done in code?
Getting Value From Main Form
Hi again
I have on the main form some text boxes that load info from a db, no problem there, I can scroll though the data with a button and when the one I want is found I push another button that will insert this info into the form. so when I push the button it loads the form and gets the value from the main form with this
pid = Val(Trim(frmMain.txtFields(0))) // txtFields(0) is the id from the db
but it doesn't matter what value it is it always returns 1.
so if I was on the second id from the db it should send that to the second form but it sends a 1 everytime.
anybody have an idea?
TIA
One Main Form
I got more than 3 forms in my app.I want to make the main form disabled when form2loads and keep it like that untill the the form2 unloads what i am trying to say is how can you make a form a sub form
Here is the problem
when I load form1 from the main form I see two forms in taskbar Main and form1. I wand form1 in Main Form Like a Sub Form
Main Form And Sub Form
hi,
I have 2 forms i.e., main and a subform. In both the forms ID and Name fields are common. In order to open the subform I have placed a command button in main form. So, once the user enters the ID or Name field in the main form and click on the subform command button, the sub form should open with the details of the given ID or Name.
Keep Form On Top Of Main Form
How can I make a small form to stay over the main one even when it lost its focus? This is for a search dialog, which must behave like the Notepad's find dialog, I don't want it on top of all other program's windows.
I know I can use API to call the Find dialog but this one is useless for me since I'm searching in a ListBox instead of a TextBox.
Reconstruct Main Form
hi, here i have some problems:
1. i have 2 forms in my project, frmLogin and frmMain.
2. when the user LOGIN with the employee id, it will load standard toolbar, and explorer bar in the frmMain. and when the user LOGIN with admin id, then it will load advance toolbar and special bars in the frmMain.
3. Let say, now the user LOGIN with employee id, and on the frmMain, got another button which let the user to change the status of employee LOGIN to admin LOGIN. so, when he click the button, it will return to frmLogin to prompt for password.
the problem here: HOW do i unload and clear all my toolbar in frmMain when user return to frmLogin second time? as i know, if i put 'end' in my frmMain unload, it will end the application......so, if i did not put 'end', my application cannot EXIT when user click exit.....so, how to deal with this?
How To Change The MAIN Form?
I have an app with one form and lots of controls on it. Works great. Now I want to split up the controls, and place half of them on another form. I did this. Now how do I change the 2nd form I added to load first?
I have form1 and form2.
Form1 is the default main form I started with, and loads first at runtime.
Form2 is the 2nd form I added.
I want form2 to be the default, and load at runtime first.
Thankie!
Main Form Focus
is ther any way to keep the focus on the main form?
my program when something happens it pops up a textbox witht h information in it, but see evrytime that happens im in the middle on typing somethign on the main form and get interuppted buy the mssage form and text boz and i mistakenly type in the messge form textbox.
so... si there any way to keep the main form on focuz if another form in your project pops up or refreshes???
Must Have Startup Form Or Sub Main()
I'm trying to compile an ActiveX.EXE class. In my class I have a Private Sub Main(). When I compile, I get an error stating, "Must have startup form or Sub Main()." I've tried changing the "Private" to everything else, but it's still not working.
Any suggestions?
Main Form Won't Unload
My main form has a menu with a mnuFileExit_Click()
so that when I select File-Exit, all forms get unloaded from memory -- and everything is fine.
However, I'd like the same code to execute when I use the X box at the upper-right of the window (y'know, "X" out of the window).
So I'm assuming that what hitting the X does is fire off the Form_Terminate event. Thus, I use the below code:
Private Sub Form_Terminate()
Call mnuFileExit_Click
End Sub
But it doesn't work. It leaves the form in memory. Multiple executions of the program, therefore, leave multiple programs hanging around in memory.
Am I making the wrong assumptions about what the X button does -- and is there another way to do this?
Thanks.
Main Form Will Not LOAD!!!!
I have a module that is my STARTINg point in my program, It loads the Splash Screen, the main form,and then close the splash screen! For some reason It will not open the main form!!! It works on my computer but not a another HP Pavilion!! If I can fix this problem,I can start shipping this program!
My main form has a SSTab, Menu, and ButtonBar Controls, Could it be one of the OCX or an out of date file?
I have:
P200mmx with Windows 98a
the HP is:
Pentium with Windows 98?
Get Value From Subform To Add To Main Form
I need to get a value from my subform and add it to my main form when it loads. I have ran the below code and it is getting the value from the subform however it is not adding it to the main.
It appears that the form loads too quickly, as if i have a break in the code it shows that it is getting the value just not putting it into the main form. If i then re open the form the field has been populated.
Should it be in another section or is there another way to pull the value onto teh main form, any ideas?!!! Thanks
Code:
Private Sub Form_Current()
DoEvents
Me.txt_testmins = Me.sbf_charge_viewESummary.Form!txt_totalmins
End Sub
How To Deactivate The Main Form
There are two forms, Form1 and Form2. On Form1 is a command button named Command1.
Here's the code:
Private Sub Command1_Click()
Form2.Show
End Sub
This would make Form2 appear, but I don't want the user to be able to access the main form, Form1, while Form2 is on the screen. I don't want to use the Hide method to hide Form1, I want Form1 to still be visible, but unclickable. How do I do this?
Hiding The Main Form
I want to hide my startup form because I want to display my tray icon only. How can it be achieved??
I tried
me.hide()
me.showintaskbar=False
But it is showing error at Application.Run(mainform) in Sub Main()
Menu Of Main Form
Hi
I want to use popmenus in my child forms but I also want to use the menu from the Main form. How can I do this, whenever I create popupmenus in my child document the menu in the Main form disappears. Do I have to copy all the menu items from the main form in my child forms? or is there an other way
Access To Form From Main
Hi
I have written a VB program that starts from Sub Main. Sub Main is in a Module and Also I have a form in my project.
How can I access to my form and it's controls from Sub Main
Thanks
|