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

Opening a Form with Query Specific Data

3
Evening all,

I'm very new to VBA and am struggling badly with this one. I'll explain what I need to do as the title is a little unclear!

I'm making an insurance calculator for classic cars, and on my welcome screen I have a button called lablled Edit Existing Quote. What I would like this button to do is, upon clicking, ask the user to enter the Reg Number (the PK in my client data table) of the client whos details they wish to edit. Once a reg number is entered and submit or something has been clicked I want that record to then appear in form view.

I've got as far as the:

DoCmd.OpenForm "frm_New_Quote", acNormal

(The form is named so because I use it to add new data as well, using the 'DoCmd.GoToRecord , , acNewRec' code, the form otherwise shows client data for the last record entered.)

I'm guessing it'll involve vbQuestion somewhere in there, or possibly some SQl...I'm really not sure. I only have a very basic knowledge of VBA and the two lines I've pasted there are about all I know! I'm staring at my VBA book but failing to find the relevant pages.

So, can anyone help me out with this one? It should run like :

Click 'Edit' button on welcome screen, then little box pops up asking for reg number, then that clients details is presented.

Please help!

P.S
my client data table is called 'Client Tbl' at the moment.
Feb 17 '08 #1
3 1506
Scott Price
1,384 Expert 1GB
Well, a general overview would be:

Base your frm_New_Qoute on a query that includes as it's WHERE criteria the text/combo/list box that you are using to enter the Reg Number. In the query builder/design view just enter the qualified name of the text box. Qualified means like this: Forms![Form name].[Control name]

Then when you click OK and the form opens, it automatically queries it's underlying data source, which in this case is the query that you created with the WHERE criteria pointing to the text box. Obviously this pop-up form needs to be open for it's values to be registered, which means that you will include the command to close that form in a later event of your frm_New_Quote.

Anything you don't understand, just ask!

Regards,
Scott
Feb 17 '08 #2
Steed
3
Hey thanks for the reply! That stuff really really wants to make sense in my brain but it can't quite stick itsself into code for me.

I'm confused as to how you go about doing this, having the system ask for a variable which then calls up the relevant data. I can make the input dialogue box using code from the help files:

Expand|Select|Wrap|Line Numbers
  1. Dim Message, Title, Default, MyValue
  2. Message = "Enter a value between 1 and 3"  ' Set prompt.
  3. Title = "InputBox Demo"    ' Set title.
  4. Default = "1"    ' Set default.
  5. ' Display message, title, and default value.
  6. MyValue = InputBox(Message, Title, Default)
  7.  
  8. ' Use Helpfile and context.
  9. ' The Help button is added automatically.
  10. MyValue = InputBox(Message, Title, , , , "DEMO.HLP", 10)
  11.  
  12. ' Display dialog box at position 100, 100.
  13. MyValue = InputBox(Message, Title, Default, 100, 100)
  14.  
  15. End Sub

Would I use that as part of a larger procedure to then use the data inputted and do something with it? Or would I add to that code itself?

Currently if you click OK on the produced dialogue box it just reopens itself, and I don't ahve a clue how to make it do something more useful.

Sorry to be so noobish, but a little more assistance would be greatly appriciated.

Thanks,

_Ed
Feb 17 '08 #3
Scott Price
1,384 Expert 1GB
Hi Ed,

No need to apologize for 'noobism' :-) On the Scripts we like to think of ourselves as 'Experts helping Experts', but the reality is more like experts helping noob's become experts.

As far as what you are attempting, it's probably going to be much much easier to create your own pop up form. Place a text box on it. Then in the query that I referred to in my first reply post, refer to this text box. The following is a query copied directly from one of my databases:
Expand|Select|Wrap|Line Numbers
  1. SELECT tblCrew.*, tblConvInformation.ConventionName
  2. FROM tblConvInformation INNER JOIN tblCrew ON tblConvInformation.ConvID = tblCrew.ConvID
  3. WHERE (((tblCrew.ConvID)=[Forms].[frmConvInformation].[txtConvID]))
  4. ORDER BY tblCrew.CrewPosition DESC;
You will notice particularly the WHERE clause and it's syntax. Once you have your query and form created, we can take a look at what more you will need to do.

Regards,
Scott
Feb 17 '08 #4

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

Similar topics

2
by: Pete | last post by:
Before I get started with the question, does anyone have a (single) good book recommendation for database design? Not an Access-specific book, but something geared toward helping me figure out...
1
by: N. Graves | last post by:
Hi, I want to have a Search Dialog box that has several text box and fields to build a search and display the results in a form. I can do everything that I need to if I us a report but I would...
3
by: Greg | last post by:
On my report I want to have an opening balance signifying all transactions up to the month selected and detailed transactions for the month selected and then a closing blance. I'm perpelexed...
1
by: Ian | last post by:
I want to open a form at a particular record, but I think I'm running into problems because the recordsource query is executing asynchronously. In the form's open event I use...
3
by: Andy Davis | last post by:
I have set up a mail merge document in Word 2003 which gets its data from my Access 2000 database. I want to set up a button on a form that: 1. runs the query to provide the dat for the merge...
2
by: Colin Halliday | last post by:
I have a Word 2003 mail merge main document (form letter) that is linked to another Word document data source for the mail merge. If I open this doc using the Word GUI, it first asks me to...
3
by: MartinR | last post by:
Hi, I'm still new to writing code in vba as I've only been introduced to access three weeks ago. I have written this code below and it executes but does not do what I want it to do. What I want is...
8
by: hoofbeats95 | last post by:
I don't think this should be this complicated, but I can't figure it out. I've worked with C# for several years now, but in a web environment, not with windows form. I have a form with a query...
6
by: martin DH | last post by:
**Urgent Need** I'll throw out the basics and any assistance is very, very, very much appreciated! Access 2003 on XP On a form (frmMain) is an option group of check boxes (ReportFrame) from...
16
by: Phil Stanton | last post by:
I have a form with a button which is supposed to open an Excel file (With lots of Macros /VBA) in it. The Excel file gets it's data from the Access program Here is the code Private Sub...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...

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.