Pop up form (add info)

sandylt

Registered User.
Local time
Today, 04:17
Joined
Mar 11, 2004
Messages
36
First post so follow me on this one. I am working on my purchase order form. If the employee needs the supplies ASAP I have an "urgentdate" field (date&time). If this field is filled then they have to explain why in the "emergency" (memo) field. What I was attempting to do is when the employee fills in the "urgentdate" field and advances a form will pop up forcing them to enter the explanation. Once they enter the information it is seen in the field on the original form. I have created the form and used the same record source and the field is on the form. I have tried many things, but cant seem to make it happen. Does anybody know how I can go about this? I have been working with Access for about two years now and know some code.
 
Welcome to the forum!

If I read you right then if you want to open the form once they enter the date, then do the following:

On the AfterUpdate Event of the date field (Right click date field - Select Properties - Select Event Tab - Click just to the right of the afterupdate entry)

Select Code editor

Enter the following code:
Code:
docmd.openform "yourformnamegoeshere"

Hope I understood your question

Andy
 
Another methods in the after update is

Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmComments"
stLinkCriteria = "[ClientID]=" & Me![ClientID]
DoCmd.Openform stDocName, , , stLinkCriteria

Set the record source of frmComments to the table that has the comments field.

Set the comments field on the frmComments to the control source in the table where you want the comments stored.

This is probably not the most fashionable way to do it but it works.
 
Ok i got it to open the form afterupdate. However when I entered the information and closed the form. The information was not stored in the correct record. It stored it in the first record of the table.

I made the form and set the form to open by the ID of the orignal form to try and match the record that the employee is working on. If they are working on ID #3 then when the info is entered the comments should be in ID#3.

Here is my code can anyone tell me what is wrong?

Private Sub UrgentDate_AfterUpdate()
DoCmd.OpenForm "Emergency", acNormal, "[RequisitionInfo]![ID]=[Forms]![RequisitionAdd]![ID]"
End Sub
 
This should work just change the form name and ID matches both forms.

Code:
Dim stDocName As String
    Dim stLinkCriteria As String
    stDocName = "frmMemo"  'Form Name here
    stLinkCriteria = "[OrderID]=" & Me![OrderID]  ' ID  Name Goes Here
DoCmd.OpenForm stDocName, , , stLinkCriteria


Andy
 
I tried and the db flipped out telling me it was an unrecognizable db format. When i repaired it deleted the record that I was testing and its gone.
 
Ok here is the deal.
I added this code to the afterupdate of the field

Private Sub UrgentDate_AfterUpdate()
DoCmd.OpenForm "Emergency", acNormal, "", "[RequisitionInfo]![ID]=[Forms]![RequisitionAdd]![ID]", , acNormal
End Sub

Then when the form is filled in I put this code in the close button

Private Sub Command5_Click()
DoCmd.RunCommand acCmdSaveRecord
DoCmd.Close
End Sub

Everything works with the exception of a window that pops up after I try to select next record (See attachment please). If I tell it to copy to clipboard it works any other option does not. How can I get this window to stop popping up. It will just confuse my users.
 

Attachments

  • popup.jpg
    popup.jpg
    54 KB · Views: 159
sandylt said:
Private Sub Command5_Click()
DoCmd.RunCommand acCmdSaveRecord
DoCmd.Close
End Sub

Try this instead:
Code:
Private Sub Command5_Click()
    DoCmd.Close acform,"yourformnamegoeshere",acsaveyes
End Sub

Let me know how you get on.

Andy
 
acSaveyes saves changes made to the design of the form, if you haven't made any then there's no point in using it
 
Correct me if I'm wrong but what you are attepting is:

Form 'A' open user inputting data blah blah
A certain condition is met and a second form pops (Form 'B') up asking for further info
The info on Form 'B' is required on form 'A' and you want to put it there as form 'B' is closed

in which case try this.

Private Sub Form_Close()

strMemo = Me.yourmemobox
Forms!FormA!MemoBox = strMemo

End Sub

I hope this Helps
Ian.
 
No that didnt work.
I keep getting this pop up window.
Im still working at it.
 
can you post a db with no data in?

So we can take a look.

Andy
 
Hi

Here is a slightly different approach I have used sucessfully many times.

My popup form has an unbound control in which you enter the value you eventually need to go onto your main form. This unbound control can be a text box or combo box or whatever you need to get the correct input.

On the close button of the pop up form I put some code such as:

Forms![calling form name]![control on calling form] = Me.[name of unbound control on pop up form]

before I issue the close command.

This forces the value from your pop up form into the correct place on the calling form, and does not require the record to be saved within the pop up form. this should stop the extra pop up appearing and annoying the users.

Hope this helps, I can explain more fully or post a sample if you need me to

Sue Powell.
 
Sue,

That worked the best so far, but I am still getting the message window.

I will attach and see if anyone can help, it would be greatly appreciated!
 

Attachments

Hi,

The reason you are getting the error message is because of the relationships set up (RI). The SHip to address needs to be completed before you can enter any comments in the Emergency form.

You could just add code to wherever you are going to trigger the emergency form to lookup up if the fields have been completed to display a msgbox or form to tell the user they need to enter the ship to address before the emergency memo can be added.

Hope this helps

Andy
 
I was getting the error message even after the data was filled in. I was making an adjustment with 200+ records already in the db the ShipTo was already completed. Can there just be another way to do this?
 
Hi

I have had a look at the sample you posted

I think the problem is that you are trying to save the record from the pop up form.

I commented out the save line and it works OK. You don't need to save from the pop up form as the RequisitionAdd form is the place where the data is held, and the data will be automatically saved when you move to the next record. If you feel you need to save the record explicitly, then do it on an event of this form.

Hope this solves the problem for you

Sue Powell
 
Tried to add a save record to the event and I still got the message. I also got an error message for the code
 

Users who are viewing this thread

Back
Top Bottom