473,396 Members | 2,036 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.

Finding record in a sub form using FindRecord

2
Hello,
I am trying to use the FindRecord function in my 2003 database.
My code is
Expand|Select|Wrap|Line Numbers
  1. Dim Orderho As Integer
  2. Orderho = Me.cboFindByOrder
  3. Forms!test!Order!OrderID.SetFocus
  4. DoCmd.FindRecord Orderho, , True, , True
It does not work when I use the variable, but will work if I put a number figure such as 12 in teh function for example
Expand|Select|Wrap|Line Numbers
  1. DoCmd.FindRecord 12, , True, , True
Is the problem with declaration of the variable?
Any help would be appreciated thanks
Peter
Sep 14 '17 #1
4 4073
PhilOfWalton
1,430 Expert 1GB
The declaration should be of the same type as the field being searched, so guessing that OrderID is an autonumber, Autonumbers are Long

Assuming that Forms!test!Order is a subform, to refer to a control on it (such as OrderID) use

Expand|Select|Wrap|Line Numbers
  1. Forms!test!Order.Form!OrderID
  2.  
It's always worth putting a halt in your code, and checking whether Forms!test!.Form!Order is actually getting the focus

Phil
Sep 14 '17 #2
NeoPa
32,556 Expert Mod 16PB
You say it does not work, yet you don't tell us what does happen. An error description is helpful for errors. If it simply doesn;t find the correct record, or move the record pointer at all, we also need to know that.
Sep 15 '17 #3
psamps
2
Thank you for your replies,
I have changed the variable to Long and added the line of code
Forms!test!Order.Setfocus before
Forms!test!Order.Form!OrderID.SetFocus
to make sure that OrderID has the focus
but it still does not work. There are no error messages either but now OrderID has the focus.
Thanks
Sep 15 '17 #4
NeoPa
32,556 Expert Mod 16PB
I assume then that what you mean but not working must be that it doesn't move from the current record. I'm afraid I can't see why. I would assume that there is something which is causing it to fail but which you haven't shared with us.

Generally I would expect code such as that to work.

I can state unequivocally that the focus was fine in the first instance as when you used the literal value 12 it did work. So, it seems clear there is something about the variable used. You could try using Val() around the reference to your variable. That should work, but it isn't the answer to your question. We can only help with that when we know what it is you aren't telling us.
Sep 15 '17 #5

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

Similar topics

2
by: vishal | last post by:
hello friends i have one php script which generates html page containing form. what i want is submit this form using php script. pls give me some idea that how can i submit form using php...
4
by: btopenworld | last post by:
I am submitting a form using an image as the link to a js file. The image calls a js function which checks fields- issuing alerts for errors - if no errors it then submits the form. I would like...
3
by: Justin Sane | last post by:
I haven't been able to select a form using getElementById. I only can select a form using the "name" property of the <form> tag. Is there another way to select a form, or is it even possible to use...
2
by: Michael Creager | last post by:
I am using VB NET 2002. How can I programmatically create a new windows form using the value of a string variable as the name of the new form? Public FrmName As String = "MDIChildFrm1" Public...
6
by: San | last post by:
Hey, I need to create a form with several text boxes in which users type in key words, press a command button on the form and it opens a matching record. Thanking you in advance.
0
by: Renato Tasso | last post by:
Please, everyone can help me ??? I wanna record DVD using visual basic.net language. How can i do ??? Thanks -- Renato Tasso
1
by: alex.gruenther | last post by:
I am new to Access and need help creating an edit record form. I've got a table called Player with attributes like name, address, phone, etc. I've created an edit player form with a combo box...
8
by: hollinshead | last post by:
Hi there i have bit of an issue. i haver this database that is purely used for searching records under certain criteria. This criteria is chosen by the user on a form using list boxes and combo...
10
by: Joe Y | last post by:
My Access DB handles product formulation and specification. In the formula form, many text boxes, such as Cost or ingredient statement, are calculated fields based on each ingredient data in the...
2
by: RachelleB | last post by:
I have one tabbed form that links to a master table. One of these tabs links to a sub form (GRN, to GRN table) and another tab to another subform (SRN, to SRN table). I can run a report that...
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
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,...
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
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...
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...

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.