• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 371
  • Last Modified:

DoCmd Open form with Open Args question, creating a condition for when to pass on the openargs

Hello, I have several forms which have forward, back, and a search box in the header as controls.  The first form has a primary key called [Call Number] which is used as a FK for the rest of the forms.  Basically the user starts on the first form and navigates through to the last and creates a new record to start the process again.  The code used for each forward and backwards button uses openargs as follows:
Private Sub Command397_Click()
    If Me.Dirty Then
        RunCommand acCmdSaveRecord
    End If

On Error GoTo Command104_Click_Err
    DoCmd.OpenForm "frmIntermediateOutcome", , , , , , Me.CallNumber
       DoCmd.Close acForm, "frmHealthOutcomeMorbidity"


Command104_Click_Exit:
    Exit Sub

Command104_Click_Err:
    MsgBox Error$
    Resume Command104_Click_Exit
End Sub

Private Sub Form_Current()
Me.CallNumber = Me.OpenArgs

End Sub

Private Sub Command104_Click()
    If Me.Dirty Then
        RunCommand acCmdSaveRecord
    End If

On Error GoTo Command104_Click_Err
    DoCmd.OpenForm "frmHealthOutcomeMortality", , , , , , Me.CallNumber
       DoCmd.Close acForm, "frmHealthOutcomeMorbidity"


Command104_Click_Exit:
    Exit Sub

Command104_Click_Err:
    MsgBox Error$
    Resume Command104_Click_Exit

End Sub

Open in new window


This creates a problem after 1 record is entered because when clicking forward from form 1, instead of opening a new record it goes to the first record of form 2 and then copies over the openargs as the call number in that form.

How can I create a condition where a new record is created if there isn't a matching [Call Number] in the table source of that form (i.e. new record with [Call Number] copied over from OpenArgs), and if there is a matching record in the table simply navigate to that record?

Any help would be excellent as I'm stumped,
Bevo
0
Bevos
Asked:
Bevos
  • 5
  • 4
1 Solution
 
Nick67Commented:
As much as I hate them and find them disgusting, you actually have a need for a tab control.
I am almost shocked top here myself say that.

What you want is a tab control on your main form.
Add one tab for each of these other forms that need to open.
On each tab, add these other forms as a subform
Link them on Master/Child as [Call number]

Post a sample if you can't get it beat into shape
0
 
BevosAuthor Commented:
Hi Nick, thanks for helping me with another question.  I'm posting the DB here.  Unfortunately, I'm not 100% sure what a tab control is even after some googling.
I was pretty happy that I got the controls to work with OpenArgs... but now this issue has cropped up.  I am debating if I should just remove these and have the user re-enter the data, but I feel like that is admitting defeat!  If you could help me figure out how to make these forms work as intended that would be super :)

Thanks again for all of your help now, and in the past,
Bevo
EE-Example.accdb
0
 
Nick67Commented:
Hi Bevos,

I need an mdb, if you can provide it, as I'm on Access 2003 at work

Nick
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
BevosAuthor Commented:
Hi sorry it took me a bit to find out why it wouldn't convert. Turns out I had two multi-value list fields that needed to be removed.  Please let me know if I can help explain anything else and thank you again for being willing to take a look at this problem.

Bevo
EE-Example.mdb
0
 
Nick67Commented:
Sorry,

I thought I had posted this.
Here's a tabbed form with subforms, all linked on master/child relationships with very little code
TabForms.mdb
0
 
BevosAuthor Commented:
Wow! This is really cool. I've never used a tab form before.  It seems to work brilliantly for data that is already present, but I have a few questions.  
When I try to make a new record I get an error as I type in call number of Study and Patient Characteristics that I must enter a value in this field.  Why might that be?
Also, after entering a new value in [CallNumber] from the tab 'study and patient characteristics' it doesn't seem to refresh the listbox and title bar you put in. Nor can I navigate to that record with the next and previous controls.  However, when the database is closed it works again (because the data is saved in the underlying tables).  

Do you have any thoughts on how to fix these?  I am trying to use requery and save record to fix the later but it doesn't seem to be working .

Thanks again, this is a really nice change (although I know you personally don't care for this style of form!)

Bevo
0
 
Nick67Commented:
I see tabbed forms get badly abused too often.
They don't really provide enough differentiation for users to recall where stuff is 'hidden'

But you actually have a good use for them, so OK, fine :)

Now, entering a brand new tblStudyCharacteristics record!
For that, you need a different tactic.

Work through the changes in the sample, and let me know
TabForms.mdb
0
 
BevosAuthor Commented:
Hi Nick, this allows each form to work really well but most of the people using this form will be near computer illiterate doctors who will be confused about what is going on.  Is there a method to do this without having it open the new form?

Thanks,
Bevo
0
 
BevosAuthor Commented:
I also get an error about MSADO 6.0.dll in this version.  Can I just remove that reference?

Sorry if I'm asking too many questions about this,
Ryan
0

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now