Solved

MSAccess Form Recordsource change

Posted on 2009-05-19
3
433 Views
Last Modified: 2013-11-28
Hello,

I am trying to change the recordsource of a form from another form. When the user clicks on the name of the client in the first form, second form should be displayed about the client which was chosen in the first form.
When I try to run this, it says 'it cannot find the frmclientssearchsub2 in the list of forms.
and highlights the
Me!frmClientsSearchSub2.Form.RecordSource = strsql
section.
I suspect the syntax should be different.
thanks,
Private Sub ClientName_DblClick(Cancel As Integer)
Dim strsql As String
 
 
Dim strwhere As String
strsql = "Select * From Assets"
strwhere = "1"
If Not IsNull(Me.Form.ClientName) Then
strwhere = strwhere & " AND LastName= '" & Me.Form.ClientName & "'"
End If
DoCmd.OpenForm ("searchform2")
 
Me!frmClientsSearchSub2.Form.RecordSource = strsql
 
 
 
End Sub

Open in new window

0
Comment
Question by:awesomejohn19
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 2

Expert Comment

by:ctpmn1
ID: 24425800
Is the name of the form you are trying to pull frmClientsSearchSub2 ? If not then you should start there.
0
 

Author Comment

by:awesomejohn19
ID: 24426354
yes the name is frmClientsSearchSub2 and it is inside searchform2
0
 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 500 total points
ID: 24429015
awesomejohn19,

1. I cannot see were you are inserting the word "WHERE" in you SQL?

2. I can even see what Field you are trying to use the "1" for?

3. If all the values in the SQL string are hardcoded, then keep things "Simple" and put them all togeather in one string, so this is "easy" to troubleshoot.

4. You should be referring to the company ID, not the Name.

5. It looks like yor final SQL is Malformed.

6. It is not clear if the  1  is really a text datatype ("1"), or a numeric Datatype (1)

In any event, this works fine for me...

JeffCoachman


Access-EEQ24422068--ChangeFormRe.mdb
0

Featured Post

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question