A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Link Forms with multiple fields



 
 
Thread Tools Display Modes
  #1  
Old April 23rd, 2010, 05:51 PM posted to microsoft.public.access.forms
T5925MS via AccessMonster.com
external usenet poster
 
Posts: 14
Default Link Forms with multiple fields

Any ideas why I get a 'Type mismatch' error with this code that I using to
open a second form linking multiple fields?

Private Sub cmdUpdatePhone_Click()
On Error GoTo Err_cmdUpdatePhone_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmEdit Location Phone Numbers"
stLinkCriteria = "[Location Name]=" & "'" & Me![Location Name] & "'" And
"[Position Code]=" & "'" & Me![Position Code] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdUpdatePhone_Click:
Exit Sub

Err_cmdUpdatePhone_Click:
MsgBox Err.Description
Resume Exit_cmdUpdatePhone_Click

End Sub

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/201004/1

  #2  
Old April 23rd, 2010, 06:39 PM posted to microsoft.public.access.forms
T5925MS via AccessMonster.com
external usenet poster
 
Posts: 14
Default Link Forms with multiple fields

Nevermind. I was using quotes incorrectly. Here's the correct syntax:

stLinkCriteria = "[Location Name]='" & Me![Location Name] & "' AND [Position]
='" & Me![Position] & "'"

T5925MS wrote:
Any ideas why I get a 'Type mismatch' error with this code that I using to
open a second form linking multiple fields?

Private Sub cmdUpdatePhone_Click()
On Error GoTo Err_cmdUpdatePhone_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmEdit Location Phone Numbers"
stLinkCriteria = "[Location Name]=" & "'" & Me![Location Name] & "'" And
"[Position Code]=" & "'" & Me![Position Code] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdUpdatePhone_Click:
Exit Sub

Err_cmdUpdatePhone_Click:
MsgBox Err.Description
Resume Exit_cmdUpdatePhone_Click

End Sub


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/201004/1

  #3  
Old April 23rd, 2010, 07:18 PM posted to microsoft.public.access.forms
Beetle
external usenet poster
 
Posts: 1,254
Default Link Forms with multiple fields

the first thing that stands out is that your operator (And) is
outside of the quotes. If [Location Name] and [Position Code]
are both text data types then the following should work;

stLinkCriteria = "[Location Name]=""" & Me![Location Name] & _
""" And [Position Code]=""" & Me![Position Code] & """"

--
_________

Sean Bailey


"T5925MS via AccessMonster.com" wrote:

Any ideas why I get a 'Type mismatch' error with this code that I using to
open a second form linking multiple fields?

Private Sub cmdUpdatePhone_Click()
On Error GoTo Err_cmdUpdatePhone_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmEdit Location Phone Numbers"
stLinkCriteria = "[Location Name]=" & "'" & Me![Location Name] & "'" And
"[Position Code]=" & "'" & Me![Position Code] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdUpdatePhone_Click:
Exit Sub

Err_cmdUpdatePhone_Click:
MsgBox Err.Description
Resume Exit_cmdUpdatePhone_Click

End Sub

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/201004/1

.

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 10:24 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.