473,397 Members | 2,099 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,397 software developers and data experts.

Open Form and Update List on Double-Click

1
I have a database where I have a form "Expense Table" it has a number of pull downs for other tables. I have a not in list error message already. But I would like to set up a double click event procedure. That would open the form for the not in list data. Add the data to it then close the from. This then up dates the table and makes the data available to select.
Don't even know where to begin.
Jun 6 '17 #1
2 1197
PhilOfWalton
1,430 Expert 1GB
First thing is may I strongly advise not having spaces in the names of forms, tables, queries, controls or field.

Equally Expenses Table is a very misleading name for a form, something like FrmExpenses would be much clearer.

That said, we have two separate processes.

Let us assume you have a field in your FrmExpenses called MissingDataID, and the form you want to open to enter the required information is called FrmMissingData.

This is the code you need on the double click.

Expand|Select|Wrap|Line Numbers
  1. Private Sub MissingDataID_DblClick(Cancel As Integer)
  2.  
  3.     If Not CurrentProject.AllForms("FrmMissingData").IsLoaded Then
  4.         DoCmd.OpenForm "FrmMissingData"
  5.     End If
  6.  
  7.     DoCmd.SelectObject acForm, "FrmMissingData"
  8.     DoCmd.Restore
  9.     If Nz(MissingDataID) = 0 Then
  10.         DoCmd.GoToRecord acForm, "FrmMissingData", acNewRec
  11.     Else
  12.         DoCmd.GoToControl "MissingDataID"
  13.         DoCmd.FindRecord MissingDataID
  14.     End If
  15.  
  16. End Sub
  17.  
It opens the form and optionally restores it. If there is a value in the MissingDataID field in the main form, it opens the new form at that record so that it can be edited.
If there is no value in the MissingDataID field in the main form, it opens the new form at a new record record so that you can add the new data.

Then after you update or add the new record you use this code

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_AfterUpdate()
  2.  
  3.     With Forms(FrmExpenses)
  4.         If !MissingDataID <> MissingDataID Then
  5.             !MissingDataID = 0
  6.             !MissingDataID.Requery
  7.             !MissingDataID = MissingDataID
  8.         End If
  9.     End With
  10.  
  11. EndSub
  12.  
That should load the new value back to the FrmExpenses.

Phil
Jun 6 '17 #2
jforbes
1,107 Expert 1GB
You may want to consider setting .AllowValueListEdits to True to bring up an editor when a value is entered that isn't in the list. You could also consider the .ListItemEditForm property if you want to supply the Form to perform the addition to the List.
Jun 7 '17 #3

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

Similar topics

7
by: Pam | last post by:
When I double click on a event in a form I want it to bring up another form and load the same data so it can be edited. I'm having a hard time doing this. The new form loads;but my file can't...
3
by: Kaur | last post by:
Hi, I have a form that has a list box (unbound) which lists all the survey names. the data is retrieved from Survey table that is made of compound key SurveyID and SurveyEditionID (both number...
6
by: michelle | last post by:
Hello everyone, We are trying to protect maximizing of a .net form if we double click on the top blue area. We tried a lot of form events, for example: DoubleClick / Click, but form is...
3
by: rino | last post by:
Hi Does anyone know how I can change the default dbl click in VS 2005 to open the source code and not the Resource editor thanks.
3
by: ali3n8 | last post by:
I am using a search form that list records in my database. On the list that shows the records that have been found I have a field called First. When I double click on this field I would like to open...
0
by: =?Utf-8?B?YXJyZW4=?= | last post by:
why i cannot open disk drive like local disk C: or D: by double click it? i need to right click it ,then there are auto, search, open,explore...,click open to open it? i have already reinstall my...
4
by: xerannyo | last post by:
my OS is windows XP SP2 my problem occured after getting infected by a wscript.exe worm but was sucessfuly removed by my kaspersky....now i cannot open my local driive in explorer by double...
6
by: Jim Devenish | last post by:
I have an unbound form that displays all the days of the year as a calendar. It has 12 rows of text boxes with either 29,30 or 31 in each row. Text box names are of the form: display_01_01,...
0
by: Salim Zaabi | last post by:
Hi I have been trying and searching for good source to the following: registering a new file extension and associating it with an icon, and when double click on the file with new extension an...
15
by: Martin Lang | last post by:
Hi All, Thanks for reading this :) I have a form A that consists of a main form A and a sub form A. In sub form A, I have a field which I can double click. Then, Main form B opens up with a...
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: 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
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.