StLinkCriteria - 2 fields

I'm building an Event at Access to visualize a report (called Carttoes) linked to the data of two fields: [codigorodada] and [caixas].
I only know how to set the linking criteria for one field, how could I put the StLinkCriteria for both fields? ...

Sponsored Links:

Related Topics

Search 3 fields from one unbound field
Basically what I'm trying to do is make a search form that will open another form from the search form that will match the records if the data was from any of the three fields.

Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Main Case Details"
stLinkCriteria = "[Serial Number]=" & "'" & Me![Search] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Is the code I use to match (via onclick) from one to another

is there a simple way, to add the following to the code, so it will search the other two fields as well?

stLinkCriteria = "[Received by Agency Inventory #]=" & "'" & Me![Search] & "'"
stLinkCriteria = "[CFU Inventory ID]=" & "'" & Me![Search] &amp


type mismatch error?
I am trying to run this function

Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Business"
stLinkCriteria = "[Numero_PA]=" & Me! [List_Participants] And "[SK_Year]=" & Me![Combo92]
DoCmd.OpenForm stDocName, , , stLinkCriteria

and I get the type mismatch error. I have looked up the fields in the tables and all of them are set to number. any ideas as to whats going on?


Multiple Field Matching with Macro
I want to have a form where I use a click button to open a new form which will then match all fields to narrow down the results.

The standard function only uses one matching point I tried more but it does not work:
Private Sub Command24_Click()
On Error GoTo Err_Command24_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "RECAP"

stLinkCriteria = "[ISIN]=" & "'" & Me![ISIN:] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command24_Click:
Exit Sub

Err_Command24_Click:
MsgBox Err.Description
Resume Exit_Command24_Click

End Sub
There are a total of 5 fields


Yet another filter issue :(
Button currently open a new form for records where thefield [Position] has a value of "Staff'

Private Sub cmdStaffLookup_Click()
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmPeopleList"
stLinkCriteria = "[Position]= 'Staff'"
DoCmd.OpenForm stDocName, , , stLinkCriteria End Sub

but I need it also to only show records where the field [Inactive] is "true" (0)

I tried using AND at the end of the stLinkCriteria


Missing Operator error
I'm getting a missing operator error.

here is my code can anyone help me figure out why

Private Sub Editloc1_Click()
On Error GoTo Err_Editloc1_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Edit Document Out File"

stLinkCriteria = "[Quarter]=" & Me![Quarter]
stLinkCriteria = "[QTR Acct Nbr]=" & Me![QTR Acct Nbr]
stLinkCriteria = "[Exception Type] =" & Me![Exception Type]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Editloc1_Click:
Exit Sub

Err_Editloc1_Click:
MsgBox Err.Description
Resume Exit_Editloc1_Click


Passing value from one form to another
I am sure that this question has been asked many times, but I cannot seem to find an answer that works. I have two forms, Form1 looks at tblChristmasCard field called CN_ID. I have created a cmd button, which opens frmAddMeToTheList with stLinkCriteria, and I want the new record to be populated with CN_ID from Form1.

Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmAddMeToTheList"
stLinkCriteria = "[CN_ID] =" & "'" & Me![CN_ID] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.GoToRecord , , acNewRec
Form_frmFRONTSHEET.CN_ID = Form_frmAddMeToTheList.CN_ID


Reusable Popup form to edit memo fields
I have a form with a few memo fields. The form is not big enough to allow users to edit these memo fields very well. So I created a new form with just one big text box and have the form pop up when the user double clicks one of the memo fields from the previous form. Looks like this:

stDocName = "frmInputMemo1"
stLinkCriteria = "[AfieldID]=" & Me![AfieldID]
DoCmd.OpenForm stDocName, acNormal, , stLinkCriteria

The popup form "frmInputMemo1" is bound to the table and field that the user wanted to edit.
This works, but just for that one memo field. I would have to create more popup forms to allow the same for the other memo fields.

How can I do this same thing but reuse the same popup form for all the memo fields


Select record in list box and open form populated with that record
For search form, n list box to filter the record. What I really want is to double click the highlighted record to display full record which in other form.

Dim stDocName As String Dim stLinkCriteria As String
stDocName = "USER"
stLinkCriteria = "[Service Tag]=" & Me![search]
DoCmd.OpenForm stDocName, , , stLinkCriteria

However, the code run to be error at stLinkCriteria. I don't know how to configure the problem since I just copied the code from my research. or do I have another way so I can display the selected record from listbox.


Syntax error missing operator(3075)
I'm kinder of new to access and I need help finding out what is wrong with the following VB coding.
I created a report from a query to search a specific record based on analyst name
I created a search from and out combo box to select the name and it will display the report with the name called.

Private Sub Command2_Click()
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Search_Report"
stLinkCriteria = "[AnalystName]=" & Me![CboAnalyst]

stLinkCriteria = "[Analyst_Name]=" & Me![CboAnalyst]
DoCmd.OpenReport stDocName, , , stLinkCriteria
Exit_Command2_Click:
Exit Sub

The analyst name on the report is in this format(john smith). Im not sure if this is the reason why I'm getting this error message


Open form to filtered records
Access 2003
Win XP - Win 7

I need to open the form "frmPeopleList" filtering the field "Position" to only those with values of "Staff".

From a button with this code:

Private Sub cmdFilter2_Click()
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmPeopleList"
stLinkCriteria = "[Position]=" & "Staff"
DoCmd.OpenForm stDocName, , , stLinkCriteria
End Sub

the above code seems to work but with a parameter box popping up prompting you to type "Staff"

I am assuming the following line of code needs some tweaking:

stLinkCriteria = "[Position]=" & "Staff


Opening report with VBA code, but opens maximized behind other open forms
I'm trying to open a report from a Button on a form, but when the report opens it hides behind the other forms on-screen, meaning you have to go to Window and then select it to bring it forward.

Here's the code I'm using in the on-click event of the first form:

Private Sub btnPrint_Click() On Error GoTo Err_btnPrint_Click
Dim stDocName As String, vResult As Integer
Dim vOption As Integer, vNow As String
vOption = opt1
If opt1 = 1 Then stLinkCriteria = "" Else stLinkCriteria = "[ReBadge]= TRUE"
If cmbBadgeType = "Delegate" Then
DoCmd.OpenReport "rptBadgesDelegates", acViewPreview, , stLinkCriteria
Else
DoCmd.OpenReport "rptBadgesAll", acViewPreview, , stLinkCriteria
End If
DoCmd.Close acForm, Me.Name


OpenForm action cancelled
in my database, I have a form button that receives the error "OpenForm action was cancelled". I could use some help on how to fix, below is the VBA code used for the button.

Private Sub cmdAddUwriter_Click()
On Error GoTo Err_cmdAddUwriter_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmUWriter"

stLinkCriteria = "[ClientNo]=" & Me![ClientNo]
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_cmdAddUwriter_Click:
Exit Sub
Err_cmdAddUwriter_Click:
MsgBox Err.Description
Resume Exit_cmdAddUwriter_Click


Opening form with passing argument
I am trying (unsuccessfully) to open a form from another form by passing a date argument.

On the first form:

Public Sub OpenAppointmentForm(vStartDate As Date)
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmDayCalendarMC"
stLinkCriteria = vStartDate
MsgBox (stLinkCriteria)
DoCmd.OpenForm stDocName, , , stLinkCriteria

This seems to work OK, as I get a message box with the correct date.
The Load event for the second form is:

Private Sub Form_Load()
If Not IsNull(Me.OpenArgs) Then
Me.txtDate = Me.OpenArgs
Else
MsgBox "No argument passed"
'-- Nothing passed, just open on the 1st record
End If End Sub

I get the message that no argument was passed.

I'm trying to set Me.txtDate on my second form to the date of the passed argument


Duplicate Entry Prevention
I am facing a problem while preventing duplicate value in field "CID". As per below code, it response good when any duplicate value enters in CID field, but it also responses the same msg while entering new CID value.

Private Sub CID_BeforeUpdate(Cancel As Integer)

Dim SID As String
Dim stLinkCriteria As String
SID = Nz(Me.Cid.Value, "")

stLinkCriteria = "Cid = " & "'" & SID & "'"

If DCount("Cid", "tblCustomerSale", stLinkCriteria) > 0 Then
MsgBox "Duplicate Customer ID.", , "Error"


Run time error '438'
I'm using the code below to filter and open a report in access 2007. When the code fires I get the following error message:

Run time error '438': Object doesn't support this property or method. Debug goes the line in bold below. I'm not a VBA coder by an means.

Private Sub Owner_Name_AfterUpdate()
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Email Exceptions By Owner"
stLinkCriteria = "[Assigned To]='" & Me![Owner Name].[ID] & "'"
DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria


Can't Navigate Records On Linked Form
I cannot navigate through records once I link one form to another. Any help would be great. Thank you!

Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmMember"
stLinkCriteria = "[FirstOfPatient ID Carrier]=" & "'" & Me![Patient ID Carrier] & "'"
DoCmd.Close
DoCmd.OpenForm stDocName, , , stLinkCriteria


Referring to a subform with VBA - database now added
I have a form, frm_Interpreter, which has a subform, frm_Language. I am trying to do a search from a form on which I have a combo box which lists all languages. Can anyone give me any pointers as to how to set out my VBA, so far I have the following attached to my cmdSearch Button, I know I need to define the frm_Interpreter and frm_Language in stLinkCriteria, but not sure how to correctly set this out.

Private Sub cmdSearch_Click()
On Error GoTo Err_cmdSearch_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frm_Interpreter"

stLinkCriteria = "[Language]=" & "'" & Me![cboLanguage] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteriaExit_cmdSearch_Click:
Exit Sub

Err_cmdSearch_Click:
MsgBox Err.Description
Resume Exit_cmdSearch_Click


Retrieving Primary Key from a listbox?
Im trying to set up a pop up window for quick viewing by double clicking a listbox value. Im having trouble finding the selected value (Primary Key) and feeding it to the popup form. In the bolded code below "output_window" is the listbox.

Error: Property let procedure not defined and property get procedure did not get a value.

Private Sub outPut_Window_DblClick(Cancel As Integer)
On Error GoTo Err_btnReviewPopUP_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Occ_Popup"

stLinkCriteria = "[Occ_ID]=" & Me!outPut_Window![Occ_ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_btnReviewPopUP_Click:
Exit Sub

Err_btnReviewPopUP_Click:
MsgBox Err.Description
Resume Exit_btnReviewPopUP_Click


stLinkCriteria with multiple criteria and NULL scenario
I am currently using the code below, but want to modify it so if one of the three fields below is NULL that it will pull records matching the other two. I could not figure it out playing around with anything I found online


Multiple Entries sorted by date
I currently run a database with a large number of clients who come through a service. To look for a particular person, I have built in a seach function with the following code, that uses a persons unique identifer number (RAISE number). This is unique to the person, not to the period in the service. Some customers are referred more than once, but all entries are stored under thier RAISE number. I would like that once the search is carried out (code for this is below), for it to show the entries with the most recent entry first (using the field called ReferralDate). Is this possible

Private Sub btnSearch_Click()
On Error GoTo Err_btnSearch_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmReferralsDischarges"

stLinkCriteria = "[RAISENumber]=" & Me![txtRAISE]
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.close acForm, "frmSearch"

l3111, Manchester, UK