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

Can I make a form goto a specific record using SQL?

The record's primary key is the report number. The form in which data
is entered or modified has this Report Number at the top. I would like
to know if I could use SQL in the VB code so that on Exit of the
'Report Number' text box, the code can scan through to see if that
report number exists and if so, jump to it. I was looking through and
thought maybe docmd.GoToRecord, but that seem to only move a specific
number of records - not via parameter.

Thanks for your help,

Cheers

Reg

Nov 17 '05 #1
1 5005
"Regnab" wrote
The record's primary key is the report number. The form in which data
is entered or modified has this Report Number at the top. I would like
to know if I could use SQL in the VB code so that on Exit of the
'Report Number' text box, the code can scan through to see if that
report number exists and if so, jump to it. I was looking through and
thought maybe docmd.GoToRecord, but that seem to only move a specific
number of records - not via parameter.


Two ways to accomplish this:

(1) If you have the entire recordset open as the RecordSource of the Form,
you can execute VBA code like (the following aircode)

Me.RecordsetClone.FindFirst "[ReportNumber] = " & Me.txtReportNumber

if ReportNumber is a numeric field, or if it is alphanumeric,

Me.RecordsetClone.FindFirst "[ReportNumber] = """ & Me.txtReportNumber &
""""

followed by

Me.Bookmark = Me.RecordsetClone.Bookmark

(2) you could take the value in the Report Number text box, build SQL, and
replace the Form's RecordSource.

I would suggest that, instead of a TextBox, you use a ComboBox... you can
limit to list, it will scroll as the user types, and they will not be able
to make a mistake and type in the wrong value. Once they get close, they
could stop typing and click to choose the proper ReportNumber from the
ComboBox' drop-down list.

Larry Linson
Microsoft Access MVP
Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: BLUE WATER | last post by:
Hi, I have managed to simplify my problem but can't seem to get this to work. I want to open up a form from a click event of another form, but not only open the form when the button is pressed...
7
by: Saintor | last post by:
What I do now is I put a value in the tag property, and using the form_current event, I run through all controls properties until the ones with the required tag value are met. Sound OK in theory,...
0
by: Jamie Pittman via AccessMonster.com | last post by:
I am currently using a form to track employee time to customer and warehouse. I want to be able to take information from one record and post this to tne next record(finish time on the first record...
8
by: Zlatko Matić | last post by:
There is a form (single form) and a combobox. I want that current record of the form is adjusted according to selected value in the combobox. Cuurrent record should be the same as the value in the...
3
by: kev | last post by:
Hi folks, I have a form for registration (frmRegistration) whereby i have two buttons. One is Save which saves record using the OnClick property. I used wizard to create the save button. The...
3
by: eighthman11 | last post by:
Using Access 2000. I have a continuous form which for simplicity sack has two fields Social Security Number and Last Name. In the header of the continuous form I have a textbox where you can...
10
by: sara | last post by:
Hi - I have been struggling with solution ideas for this now for almost 2 weeks, and have not been able to figure this out. I have a user who creates a Purchase Order (tblPOData). In some...
36
by: beebelbrox | last post by:
Hi, I am new VB programming in Access and I am requesting help with the following code. WIndows OS MSaccess 2003 This code is attached to an unbound form that will display a specific recordset...
4
by: Harlequin | last post by:
I have a question concerning the need to trigger events within a "child" subform which is itself enbedded within a master "parent" form and which is accessible via a tab in the parent form. Becuase...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
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.