Want to combine some code but not sure how

SD23

Registered User.
Local time
Today, 05:55
Joined
Jun 13, 2006
Messages
60
I have this code which pulls up specific forms based on 'dsuf'. If dsuf = RGA, it pulles up the forms with RGA. I have another field called dpre. 'dpre' and 'dsuf' make up the forms ID. dpre and dsuf are stored in a table. Is there a way to combine these two groups of code so that if a form has an ID=dpre and dsuf, that form gets pulled out. For example,

if the user inputs dpre=RGA, and dsuf=SHA, the code will pull out the form with the ID=RGA SHA. dpre and dsuf are both text fields. I was thinking maybe use a for loop that goes through each row of the table and see which row has the specific dpre and dsuf (not sure how to write the VB code for that). Any suggestions would be very helpful. I am really pressed on time so your help would greatly be appreciated. Thanks in advance.


Code:
DoCmd.OpenForm "Dockets Data Input Form", acNormal, "", "", , acNormal
DoCmd.GoToControl "Patent Type"
DoCmd.FindRecord Forms![Invention Disclosure Input Form]![dsuf]

DoCmd.OpenForm "Dockets Data Input Form", acNormal, "", "", , acNormal
DoCmd.GoToControl "Prefix"
DoCmd.FindRecord Forms![Invention Disclosure Input Form]![dpre]
 
Dim stLinkCriteria As String

stLinkCriteria = "[Prefix] = '" & Me.dpre & "'" & " And [Patent Type] = '" & Me.dsuf & "'"
DoCmd.OpenForm "Dockets Data Input Form", , , stLinkCriteria

Hope This Helps.
 
That code does not give me the right results. It says "Enter Parameter Value." Not sure what to do with that. Is there anyway I can use my initial code because it gives the correct results but only when I do them seperately. I need a AND so they can find the complete ID (dsuf and dpre).
 
I may need a little more info on your setup.
How are you getting your values for dsuf & dpre? If text boxes then:
Try assigning to variables first before opening your form.

Also for future reference try not to use spaces in your (object names, Table names, field names, etc.) it makes it easier to reference them and not have to enclose them in quotes and brackets.

Code:
    Dim strdsuf, strdpre as String
    strdsuf = [I]Me.txtboxFor_dsuf_Input[/I]
    strdpre = [I]Me.txtboxFor_dpre_Input[/I]

    stLinkCriteria = “[Prefix] = ‘” & strdpre & “’” & “ And [Patent Type] = ‘” & strdsuf & “’”
    DoCmd.OpenForm "Dockets Data Input Form", , , stLinkCriteria
 
Last edited:

Users who are viewing this thread

Back
Top Bottom