473,765 Members | 2,024 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Form navigation buttons do not show correct position

Hello
I have a form to enter names and some other personal information.
When a name is entered, it is checked against existing records: maybe,
such name was entered before? If yes, user is notified and asked, would
you like to see the previous record? If user answers yes, form on the
screen is scrolled to the record with the same name. All works well,
apart from number of record between navigation buttons: it is still the
same number of the last added record! This is very misleading. I need
the correct number of record.

Interesting that despite being shown as for example "30 of 30", if to
click Go To Last button, the form returns to the last record and
navigation buttons still show "30 of 30", in this case correctly.

A code, which processes the search is:

Private Sub Form_AfterUpdat e()
Dim rst As DAO.Recordset, strStudent As String, Resp
Set rst = Forms!frmStuden ts.RecordsetClo ne
With rst
strStudent = "[Student Name] = '" & Me![Student Name] & "' AND
SURNAME='" & Me![Surname] & "'"
rst.FindFirst strStudent
If rst.NoMatch Then
Else
Resp = MsgBox("There is a student with the same name. Would you
like to see?", vbYesNo, "CON Faculty waiting lists")
If Resp = vbYes Then
Call FindStudent(Me![Student Name], Me!Surname)
End If
End If
End With
Set rst = Nothing
End Sub

Public Sub FindStudent(Stu dentName As String, Surname As String,
Optional Age As Integer)
Dim rst As DAO.Recordset, strStudent As String, F As Form
Set F = Forms("frmStude nts")
Set rst = F.RecordsetClon e
With rst
rst.MoveFirst
strStudent = "[Student Name] = '" & StudentName & "' AND SURNAME='" &
Surname & "'"
If Not IsMissing(Age) And Age <> 0 Then strStudent = strStudent & " AND
AGE=" & Age
rst.FindFirst strStudent
If rst.NoMatch Then
MsgBox "There is no such student.", vbOKOnly, "CON Faculty waiting
lists"
Else
F.Bookmark = rst.Bookmark
End If
'End If
End With
Set rst = Nothing
End Sub

Any help will be greatly appreciated.
Galka

Dec 14 '05 #1
1 2544
I see a couple of problems.

1) In the line where you assign the Surname as criteria, you are using
apostrophes (single quotes) as the text delimiter. This will work until you
run across a name that has an apostrophe in it, such as O'Hare. If you
double up the double quotes, that'll tell VBA that you want the double quote
as part of the string instead of as a delimiter. Replace each apostrophe
with 2 double quotes and that'll take care of the problem. You're probably
safe on the first name, but you could do the same thing there also if you
want to.

Example:
strStudent = "[Student Name] = '" & Me![Student Name] & "' AND SURNAME=""" &
Me![Surname] & """"

2) In your search, you're searching for FindFirst. This will give you the
first match found. The new entry has already been saved to the table, so is
available to be found. In fact, since you're making the original check in
the form's AfterUpdate event, I would suspect you'll always find a match.
The AfterUpdate event fires after the record has been saved, so when doing a
FindFirst, you'll always find at least the record you just entered.

This would normally be handled in the form's BeforeUpdate event. It would be
used to allow you to abort the current record and go to the other one. Even
better, you may want to make this check as soon as both the first name and
last name textboxes are filled in. This would save the user from filling in
a whole record, just to find that one already exists. Advise the user that
if they fill in the record by filling in the first and last names first,
that they may not have to complete the record if one already exists. Most
folks, not wanting to waste their time, will make sure they fill in the name
fields first. These two fields should also be 0 and 1 in your tab order. If
the users chooses to fill in the fields in a different order, the check will
still happen when these two fields are completed, they've just wasted their
time filling in the other fields if it wasn't needed.

--
Wayne Morgan
MS Access MVP
"Galka" <ga****@mail.ru > wrote in message
news:11******** **************@ g44g2000cwa.goo glegroups.com.. .
Hello
I have a form to enter names and some other personal information.
When a name is entered, it is checked against existing records: maybe,
such name was entered before? If yes, user is notified and asked, would
you like to see the previous record? If user answers yes, form on the
screen is scrolled to the record with the same name. All works well,
apart from number of record between navigation buttons: it is still the
same number of the last added record! This is very misleading. I need
the correct number of record.

Interesting that despite being shown as for example "30 of 30", if to
click Go To Last button, the form returns to the last record and
navigation buttons still show "30 of 30", in this case correctly.

A code, which processes the search is:

Private Sub Form_AfterUpdat e()
Dim rst As DAO.Recordset, strStudent As String, Resp
Set rst = Forms!frmStuden ts.RecordsetClo ne
With rst
strStudent = "[Student Name] = '" & Me![Student Name] & "' AND
SURNAME='" & Me![Surname] & "'"
rst.FindFirst strStudent
If rst.NoMatch Then
Else
Resp = MsgBox("There is a student with the same name. Would you
like to see?", vbYesNo, "CON Faculty waiting lists")
If Resp = vbYes Then
Call FindStudent(Me![Student Name], Me!Surname)
End If
End If
End With
Set rst = Nothing
End Sub

Public Sub FindStudent(Stu dentName As String, Surname As String,
Optional Age As Integer)
Dim rst As DAO.Recordset, strStudent As String, F As Form
Set F = Forms("frmStude nts")
Set rst = F.RecordsetClon e
With rst
rst.MoveFirst
strStudent = "[Student Name] = '" & StudentName & "' AND SURNAME='" &
Surname & "'"
If Not IsMissing(Age) And Age <> 0 Then strStudent = strStudent & " AND
AGE=" & Age
rst.FindFirst strStudent
If rst.NoMatch Then
MsgBox "There is no such student.", vbOKOnly, "CON Faculty waiting
lists"
Else
F.Bookmark = rst.Bookmark
End If
'End If
End With
Set rst = Nothing
End Sub

Any help will be greatly appreciated.
Galka

Dec 15 '05 #2

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

Similar topics

16
3198
by: Picho | last post by:
Hi all, Is there any .NET way (I am not rulling out API usage) to add button(s) to a form's title bar? I found some non-.NET solutions that did actually work in VB6 but not in the ..NET forms... I tried painting, but the paintaing area provided by the form is only the client area - no visible way to paint on the title bar.
15
4660
by: Steve | last post by:
I have a form with about 25 fields. In the BeforeUpdate event of the form, I have code that sets the default value of each field to its current value. For a new record, I can put the focus in any field to start. If I edit that field and then click on the new record button in the navigation buttons, the form goes to a new record and each field has the default value of the previous record. If I put the focus in any field to start, edit that...
0
2702
by: misscrf | last post by:
I am currently working on a database, in 3rd normal form, which is for candidates who apply for a job with the law firm that I workd for. My issue is with good form design. I have a main form. Then I have 3 pages on a tab control ( 4 if the type of candidate validates that is is to be shown) Each page has a subform. The subforms can be either single or continuous, I think I am still deciding what I want to lock down this entry...
18
2987
by: Colin McGuire | last post by:
Hi - this was posted last weekend and unfortunately not resolved. The solutions that were posted almost worked but after another 5 days of working on the code everynight, I am not further ahead. If you do have any ideas I would really like to hear them. Thanks Colin - 0 - 0 - 0 - I want a glorified popup/context menu on a button that shows only when
3
4021
by: Jack Russell | last post by:
I want to add navigation buttons to a tabcontrol (somewhat like excel) How do I get the "tabs" to offset to the right so that I can draw the buttons on the left? TIA -- Remove norubbish to reply direct Jack Russell
3
6459
by: zhouzhendong | last post by:
I have a form that shows a table in single form format. how can I know the position of the record the form is current showing so that I can enable or disable some buttons according to the position information. For example if the form is showing the first record I need to disable the Previous button, and for the last record I need to disable the Next button, etc. Thanks
1
1194
by: erick-flores | last post by:
Hello all quick question, how do I make my form to not show the record navigation at the botton/left of the form. I just want to use my form for input data, but i dont want to see that navigation bar. Thank you
1
3466
by: grabit | last post by:
Hi Peoples i have a search page with a form field "subject" on my results page i have a paging routine . the first page lists its 10 records no trouble but when i click the "next" link i get a error telling me "subject is not defined in form" How can i overcome this please. I will post the page down to the end of the paging routine coz its not very long anyway. <cfquery name="searchResults" datasource="#dsn#"> SELECT threadID, posttype,...
2
1771
tharden3
by: tharden3 | last post by:
I have a question for you guys, I'm designing a website. Before I go any further, I'd like to get my navigation bars on the left side up and running. The site is themed to a bumblebee 'black and yellow' color scheme with nectar and honey and all that jazz. It should actually look pretty sweet when it's all done, no pun intended ;) What I was trying to do was have the colors on the nav bars invert when you hover over them. I tried achieving this...
0
10163
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
10007
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
9957
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
9835
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8832
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
7379
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...
0
5276
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3924
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
3532
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.