473,396 Members | 1,989 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,396 software developers and data experts.

how to open specific records through vba

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdsearch_Click()
  2.   Dim db As Database
  3.   Dim s As Recordset
  4.   Dim s1 As String
  5.   Dim i As Integer
  6.   Dim val As Recordset
  7.   Set db = CurrentDb()
  8.     Set s = db.OpenRecordset("Zone1new")
  9.      If s.EOF = False Then
  10.     Do While Not s.EOF
  11.        s1 = s("BldgNo")
  12.        If Me!txtbldgno.Value = s1 Then
  13.        DoCmd.OpenForm "Zone1new subform", acNormal, , "BldgNo=" & s1, , acDialog
  14.          'Like ""*" & s1 & "*"")}"
  15.        End If
  16.       s.MoveNext
  17.      Loop
  18.    End If
  19. End Sub
where is it worng in docmd i do not understand???pls help
Nov 17 '14 #1
4 941
Seth Schrock
2,965 Expert 2GB
Do you get an error message? What happens when this code runs?
Nov 17 '14 #2
" Datatype mismatch in criterion section" this is the runtime error i get .???pls help
Nov 18 '14 #3
Seth Schrock
2,965 Expert 2GB
Then I'm going to guess that that the field BldgNo is a text data type, in which case you would need single quotes around your text, like this (line #13):
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenForm "Zone1new subform", acNormal, , "BldgNo='" & s1 & "'", , acDialog
Nov 18 '14 #4
Thank you very much.Its working great. thank you.
Nov 19 '14 #5

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

Similar topics

9
by: BLUE WATER | last post by:
Help, When I am finished entering in data into my form A, I press the save button that saves this new data to a new record. However I would like my other form to open at a specific record, the...
6
by: RC | last post by:
My code below will loop through all the records in the table, and when the if statement is true it goes to the ***Me.ContainerNumberProductsTable = GETContainerNumber.Value*** bit like should but...
4
by: Stinky Pete | last post by:
Hi, In order to keep the file that's in development up to date with the reference (and still used) file, I need to regularly import the original main table and then physically select and append...
1
by: hamachi | last post by:
I want to open a specific form when a table record is 'loaded'. I have a large table that contains different client records. Thank you for your assistance.
1
by: HansyW | last post by:
I have a stored procedure MY_proc which returns records with a variety of IDs (X, Y, Z) . I would like to open stored procedure and select all records where ID=X before I continue my process....
16
by: mim77 | last post by:
Hi, I'm very rusty with Access programming. I hope someone can help me. I'm trying to include a count of the number of specific records in a field. Values for the records in the field are either...
3
by: Okonita via DBMonster.com | last post by:
Hi all, Working on a little shell script to remove specific records from a flat file. I have scanned a one or two script books and googled for answers but have no success. Can someone show me how...
1
WyvsEyeView
by: WyvsEyeView | last post by:
I have a dataset subform on which I want to lock a field for just two specific records. Each record has a type_id and a desc field. I want to test the value of the type_id field for the current...
3
by: mhegazy | last post by:
Is it possible for an access form to filter specific fields in the record source table so the user can deal with them only a part form the rest of the table fields. The table contains many fields...
4
by: shawnntjr | last post by:
Hi all, I am quite new to the VBA language, so please forgive me if I am not using the correct terms. I have a table that has a column for File Path (Z:\) and another column for File Name...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...

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.