473,799 Members | 2,693 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DoCmd Open Form

55 New Member
After displaying search results, I want to be able to double click the identity number field and then the input form SubmissionDetai ls becomes the display form for the results of the data matching value of the selected identity number. With my code below I get a data type mismatch error. Please help me.......
Expand|Select|Wrap|Line Numbers
  1. Private Sub IdentityNumber_Click()
  2. On Error GoTo IdentityNumber_Click_Err
  3.  
  4.     On Error Resume Next
  5.     If (Form.Dirty) Then
  6.         DoCmd.RunCommand acCmdSaveRecord
  7.     End If
  8.     If (MacroError.Number <> 0) Then
  9.         Beep
  10.         MsgBox MacroError.Description, vbOKOnly, ""
  11.         Exit Sub
  12.     End If
  13.     On Error GoTo 0
  14.     DoCmd.OpenForm "SubmissionDetails", acNormal, , "[IdentityNumber]=" & IdentityNumber, , acDialog
  15.     'DoCmd.OpenForm "SubmissionDetails", acNormal, "", "[IdentityNumber]=" & IIf(Nz(IdentityNumber.Value) = vbNullString, "No value.", IdentityNumber.Value & "."), , acDialog
  16.  
  17.     'IIf(Nz(IdentityNumber.Value) = vbNullString, "No value.", "Value is " & IdentityNumber.Value & ".")
  18.  
  19.     If (Not IsNull(IdentityNumber)) Then
  20.         TempVars.Add "CurrentID", "[IdentityNumber]"
  21.     End If
  22.     If (IsNull(IdentityNumber)) Then
  23.         TempVars.Add "CurrentID", "Nz(DMax(""[IdentityNumber]"",[Form].[RecordSource]),0)"
  24.     End If
  25.     DoCmd.Requery ""
  26.     DoCmd.SearchForRecord , "", acFirst, "[IdentityNumber]=" & TempVars!CurrentID
  27.     TempVars.Remove "CurrentID"
  28.  
  29.  
  30. IdentityNumber_Click_Exit:
  31.     Exit Sub
  32.  
  33. IdentityNumber_Click_Err:
  34.     MsgBox Error$
  35.     Resume IdentityNumber_Click_Exit
  36.  
  37. End Sub
Feb 16 '09 #1
5 4320
NeoPa
32,579 Recognized Expert Moderator MVP
As a full member now, you should know that we expect your code to be posted in [code] tags (See How to Ask a Question).
This makes it easier for our Experts to read and understand it.

Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.

Please use the tags in future.

Administrator.

PS. Please indicate (at least) which line the reported error occurs on.
Feb 16 '09 #2
Lebbsy
55 New Member
Thank you NeoPa. I tried to do so but my window would allow me to insert tags so I ended up sending without them. Anyway just figured out where the problem was. Instead of making the IdentityNumber on the right a string, I had made it a number. So I just put some quotes around it and it was solved.
Feb 16 '09 #3
missinglinq
3,532 Recognized Expert Specialist
My guess is that [IdentityNumber] is defined in your table as Text, which it should be, so your Where clause

"[IdentityNumber]=" & IdentityNumber

needs to be

"[IdentityNumber]= '" & Me.IdentityNumb er & "'"

Linq ;0)>
Feb 16 '09 #4
Lebbsy
55 New Member
Thanks missinglinq,

I realised that that was the problem. Thanks for the reply.
Feb 16 '09 #5
NeoPa
32,579 Recognized Expert Moderator MVP
@Lebbsy
No worries then. Maybe this will help :

Tags are done as matching pairs where the opening one is surrounded by [...] and the closing one by [/...]. A set of buttons is available for ease of use in the Standard Editor (Not the Basic Editor). The one for the [ CODE ] tags has a hash (#) on it. You can choose which editor to use in your profile options (Look near the bottom of the page).
Feb 16 '09 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
4110
by: W. Adam Glab | last post by:
"DoCmd.OpenForm "Owner Master Form", acNormal, , , acReadOnly" I am trying to open a form from within another form, however when i do that the two field like for example"Owner_ID does not match Owner_ID" on the open form.Any ideas how to correct it. Thanks
2
3307
by: chanchito_cojones | last post by:
hi there, I am needing some help with a database I am putting together. The database works off of a main Form, which then has buttons on it that will open up other forms. The problem I am having is that if I am updating any information on the current record, and then open one of the other forms, the new form will not show the updated information. I realize that a simple macro solves this problem by basically closing the first form,...
3
4521
by: Lyn | last post by:
Hi, I have a Search input form which collects from the user a person's name. I am using LIKE with a "%" suffix in the SQL so that the user does not have to type in the full name. When they hit the Search button, a query is run to search the Person table for a match. This produces a recordset (I am using ADO). If the RecordCount is zero, they get a No Match message. If the RecordCount is 1, a DoCmd.OpenForm is performed to open the...
15
3901
by: Thelma Lubkin | last post by:
formA determines some_where and some_value and issues docmd.close ,Me docmd.openform "formB", , ,some_where, , ,some_value formB receives the correct some_where and some_value After completing its work formB issues docmd.close ,Me docmd.openform "formA"
8
13215
by: John Welch | last post by:
I have a command button with the following code: DoCmd.OpenForm "frmSearchAssignments", , , "SearchAssignmentID = 1" (SearchAssignmentID is the PK, auto number) When it runs, the form opens but shows all records, rather than going to the one I want. If I look at the form in design view, it shows 'SearchAssignmentID=1' (without quotes) as the filter in the properties list. frmSearchAssignments is bound to a query qrySearchAssignments....
2
6870
by: Mike | last post by:
I am trying to open a search results form based on the input from a prompt form. I am using the following code: --- Begin Code --- Private Sub btnSearch_Click() 'Dim Variable and assign data Dim srce As String, fstnme As String, lstnme As String, bidnum As String srce = Me.Source_Control If Not IsNull(Me.Text18) Then
3
2738
by: news.onet.pl | last post by:
Hello! I have a question concerning to open the reports. I know that DoCmd.OpenReport is a obsolete form of opening the reports, but how to implement opening reports in VB using another VB code? I mean also OpenForm, OpenQuery etc. Thank you in advance for help Marcin
1
2032
by: rdsandy | last post by:
Hi, I am using Access 2003. I have a list box on a form which has 6 columns in it, with data taken from a table. I have an unbound text box which holds the ID number for the selected item in the list box. I have a command button which I want to use to open another form on that record. At the moment it opens the other form but only to the first record. The other form has its recordset set to the same table as what the list box displays...
5
11158
by: phill86 | last post by:
Hi I have a main form that holds records for scheduled meetings, date time location etc... in that form i have a sub form that has a list of equipment resources that you can assign to the meeting in the main form. I have two buttons in the sub form one for selecting and copying all the records and another for pasting the records this enables me to copy and paste the equipment resources from one scheduled meeting to another. The buttons are...
0
9689
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9550
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10495
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10269
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10248
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9085
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7573
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4148
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.