Full Version: Help With If Statement To Open Form And Go To Record
UtterAccess Forums > Microsoft® Access > Access Forms
I have a continuous form where for each record on the form i have a button that says "Edit/View". The record source for this continuous form is a query that draws records from a table but has associated tables where some of the information is entered. In this example, it lists the obligations for both Contracts and Grants, but the actual background info on a contract or grant is stored in different tables and is entered via different forms. I would like the user to be able to go to the record in either the contract form or the grant form depending on what record they click on. I have been playing with an if then statement to do this. The problem is that when it executes it starts to tell me that i need to enter parameter values. I am not sure why the main contract or grant form is not recognizing the record and updating the subforms. . I believe it is flagging because of what is in the on open command in the contract or grant forms....which are merely requeries for lists and such. Here is the on open code for the grants form. The first flag i get is on the listtraining.requery
DoCmd.GoToRecord , , acNewRec
'requery lists
'enable/disable main form fields
Me.GrantNumber.Enabled = False
Me.GrantStart.Enabled = False
Me.GrantEnd.Enabled = False
Me.StateID.Enabled = False
Me.ProgramID.Enabled = False
Me.Save.Enabled = False
Me.New.Enabled = True
Me.Get.Enabled = True
Me.OAGID.Enabled = False
Me.OAG_Save.Enabled = False
THere is the code for my button on the continuous form.
If [contractid]="0" Then
Docmd.openform "frm_grant", acNormal,,"[grantid]=" & Me!GrantID
Docmd.openform "frm_contract", acNormal,,"[contractid]=" & Me!ContractID
End If
What is the data type for contractID and grantID
You have this
If [contractid]="0" Then
Docmd.openform "frm_grant", acNormal,,"[grantid]=" & Me!GrantID
Docmd.openform "frm_contract", acNormal,,"[contractid]=" & Me!ContractID
End If
In the IF..THEN you have the zero in quotes which implies a text field but in the docmd for the frm_contract you have the contractID as numeric.
Datatype for the IDs is a number. Let me try changing that. Thanks.
Let us know how it works out
everything seems to be working fine now. thanks
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.