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

Command Button Trouble

44
How can I get a command button to open up a pop up form with information related to the main form? I have an "Employees" form with a cmdbutton to open "SpsInfo" form. When the cmd button is clicked i am able to enter the information on the spouse, but if i go back to the main form and click on the cmd button the information is gone on the form. I need the cmd button to pop open the "SpsInfo" form with the related spouse on the main form. How can i keep the information from disappearing?
May 14 '08 #1
5 1217
wassimdaccache
222 100+
How can I get a command button to open up a pop up form with information related to the main form? I have an "Employees" form with a cmdbutton to open "SpsInfo" form. When the cmd button is clicked i am able to enter the information on the spouse, but if i go back to the main form and click on the cmd button the information is gone on the form. I need the cmd button to pop open the "SpsInfo" form with the related spouse on the main form. How can i ke ep the information from disappearing?
I think the better way now is to use the wizard of MS access. assign a button and then choose open form here you can chose the criteria you want (usually primary key = to the other primary key)

try it it might be the answer of your post.


Have nice day


WASSIM S DACCACHE
May 14 '08 #2
Stewart Ross
2,545 Expert Mod 2GB
Hi Zulema. You have not provided full enough details of where exactly the spouse information is stored, and what the recordsource is for your pop-up form. I assume that the spouse field or fields in the separate form are also part of the same employee table and not a separate table. Normally, the relationship of spouse to employee is 1-1 so a separate table is not used to store such data. Please advise if this is not the case here.

It would appear that either (a) your pop-up form is not bound to the spouse details field in the underlying query or table, or (b) you are not filtering the employee ID correctly when you open the spouse form. In case (a) if you enter data into an unbound text box the data is lost when the form is closed. In case (b) the data is still available for some record that you have overwritten, just not the one you think it should be.

I suspect that case (a) is more likely.

We need to know the recordsource of your pop-up form, and how you are opening it (ie what filter is being applied to make sure it is the correct employee's record that is opened).

-Stewart
May 14 '08 #3
Zulema
44
Thanks for responding Stewart. The spouse fields are are part of a separate table "SPS INFOtbl". This is the code on the command button to open the pop up form:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command444_Click()
  2. On Error GoTo Err_Command444_Click
  3.  
  4.     Dim stDocName As String
  5.     Dim stLinkCriteria As String
  6.  
  7.     stDocName = "frmSPS INFOtbl"
  8.  
  9.     stLinkCriteria = "[SS#]=" & "'" & Me![SS#] & "'"
  10.     DoCmd.OpenForm stDocName, , , stLinkCriteria
  11.  
  12. Exit_Command444_Click:
  13.     Exit Sub
  14.  
  15. Err_Command444_Click:
  16.     MsgBox Err.Description
  17.     Resume Exit_Command444_Click
  18.  
  19. End Sub
May 14 '08 #4
Stewart Ross
2,545 Expert Mod 2GB
Hi Zulema. Code opening the form seems OK - assuming that your ID field SS# is indeed a string (going by the single quotes before and after the reference to the field in the Docmd.Openform line).

One other possible cause of this apparent 'loss' of data is if the form frmSPS INFOtbl is opened in Add mode instead of Edit. Open the form in design mode and check its Allow Edits property, which should be set to Yes. If it is set to No and Allow Additions set to Yes you will be able to add new records, but not see or edit any existing data.

If the properties are OK then check directly at table level whether or not data is being stored in your spouse info table. If it isn't, either form frmSPS INFOtbl is bound to a non-updatable source, or the control you are updating is not bound to an underlying field, or the record filtering on the SS# field is not matching any existing records.

One other thing: as you are using a separate table for spouse information, if you are adding new staff records and then adding spouse data from within that entry on your staff form you must save the staff record before opening the spouse form. Otherwise, there is not yet an employee reference to match.

The record save can be achieved by adding
Expand|Select|Wrap|Line Numbers
  1. if me.dirty then me.dirty=false
before the Docmd.openform statement.

-Stewart
May 15 '08 #5
NeoPa
32,556 Expert Mod 16PB
Zulema,

As a full member now, you should know that we expect your code to be posted in [code] tags (See How to Ask a Question).
This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.
Please use the tags in future.

ADMIN.
May 16 '08 #6

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

Similar topics

2
by: Paul A. Wilson | last post by:
I'm new to Tkinter programming and am having trouble creating a reusable button bar... I want to be able to feed my class a dictionary of button names and function names, which the class will make....
8
by: bearophileHUGS | last post by:
Hello, I have four things to ask or to suggest, sorry if they seem basic or already discussed. ------------------- I am still ignorant about Tkinter. This little program, after pressing the...
8
by: dakman | last post by:
Recently, I have been needing to do this alot and I can never find a way around it, the main reason I want to do this is because for example in the application I am making right now, it creates a...
2
by: Chris Bolus | last post by:
I'm a teacher using MS Access on an RMConnect 2.4 network. On some workstations both I and my students sometimes get an error message when attempting to insert a command button on a form which...
14
by: Kevin | last post by:
A couple of easy questions here hopefully. I've been working on two different database projects which make use of multiple forms. 1. Where's the best/recommended placement for command buttons...
3
by: rudeman76 | last post by:
Hi, I have a form that has no menu bar (so people cannot go playing) and when the admin presses the admin button they have to enter in a password. After they enter in the password the menubar...
6
by: kpfunf | last post by:
I have one form called Accounts, on which there is a command button called EnterNewTransactionButton. This opens another form called Transactions. I want to add some code that will take the value of...
3
by: myth0s | last post by:
Hello! In VB.NET I have a GridView that shows a list of dates and beside each date there's a delete button. For a reason I don't know, the delete event seems to be fired twice, but I have...
1
by: eHaak | last post by:
A couple years ago, I built a database in MS Access 2003. I built the form using macros in some of the command buttons, and now I’m trying to eliminate the macros and just use visual basic code. ...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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...
0
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.