473,322 Members | 1,425 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

DoCmd Open Form

55
After displaying search results, I want to be able to double click the identity number field and then the input form SubmissionDetails 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 4300
NeoPa
32,556 Expert Mod 16PB
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
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 Expert 2GB
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.IdentityNumber & "'"

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

I realised that that was the problem. Thanks for the reply.
Feb 16 '09 #5
NeoPa
32,556 Expert Mod 16PB
@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
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...
2
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...
3
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...
15
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...
8
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...
2
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...
3
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?...
1
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...
5
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.