Code help with Forms

Weekleyba

Registered User.
Local time
Today, 11:26
Joined
Oct 10, 2013
Messages
593
Ok...I've been working on this and cannot quite get it to work.
banginghead.gif

The user can add a project by clicking the button.
There is some validation of control in the before update...works good.
The user can then select the 'Open Contract' button.
There is some validation of control in the before update...works good.

Two problems:

1. When you click the close button in F_Contract, you have to click it twice. I see why this is happening in my code but, I don't know how to fix it. I simply want to click the button once and close. How do I fix this code and still get the validation of control to work?


Code:
Private Sub ButtonClose_F_Contract_Click() On Error Resume Next If Me.Dirty Then DoCmd.RunCommand acCmdSaveRecord 'This trys to save but the BeforeUpdate event fires which has the Public Function in it. Else DoCmd.Close End IfEnd Sub
2. When the F_Contract is closed, I cannot get the combo box, cboContract to land on the TEMP contract number that was generated in F_Contract.
If I choose …..listcount -1, it gives me the next to last in the list. Which is expected. But if I choose ….listcount , (with no "- 1" at the end) then it gives me a blank. How do I correct this?


Code:
Dim LastRow As Integer LastRow = Forms!F_Project!SF_Contract!cboContract.ListCount ctlCombo.Value = Forms!F_Project!SF_Contract!cboContract.ItemData(LastRow)

See my attached sample database.
Thanks for any help.
 

Attachments

I'm getting super frustrated with this!
I thought I had it working....and your change is good but, now I can't figure out what is wrong.

Can you PLEASE take another look at this?

Problems:
1. Add new project, click on 'Open Contract'. Contract opens with TEMP number. All good. Now close it and it still will not show the TEMP number in Combo without dropping down to select it. I'm trying to have the contract number in the combo already loaded and generate the record in the SF_Contract.

2. Another problem is, when in the F_Project with a Contract number in the SF_Contract and you click the 'Open Project' is does not go to that specific Contract. Maybe I've been at this to long today.....

Can you help me understand what I am doing wrong?
 

Attachments

I'm getting super frustrated with this!
I thought I had it working....and your change is good but, now I can't figure out what is wrong.

Can you PLEASE take another look at this?

Problems:
1. Add new project, click on 'Open Contract'. Contract opens with TEMP number. All good. Now close it and it still will not show the TEMP number in Combo without dropping down to select it. I'm trying to have the contract number in the combo already loaded and generate the record in the SF_Contract.

2. Another problem is, when in the F_Project with a Contract number in the SF_Contract and you click the 'Open Project' is does not go to that specific Contract. Maybe I've been at this to long today.....

Can you help me understand what I am doing wrong?
Hi. For Problem #1, I must be missing a step. Here's what I did:

  1. I opened your database and the F_Project form automatically opens up
  2. I click on the Add New Project button and the form goes to a blank record
  3. I enter a Project Name and select an engineer from the dropdown
  4. I click on the Open Project button and get an error
What step am I missing?
 
Maybe this little database is corrupted some how.??
I'll start from scratch and see if that works.
If not I'll post it again.
 
I haven't been following the previous thread but I've got past that issue.
However you'll still have issues on the subsequent form.
I think it needs a redesign but as I'm not sure what you're trying to do. I'll leave others to advise
 

Attachments

So I've been working on this problem, this weekend and I think I have it.
Can anyone take a look at the attached sample database and let me know if this is:
a. A good approach
b. Correct coding

Any other comments welcomed too.
Thanks!
 

Attachments

Users who are viewing this thread

Back
Top Bottom