473,725 Members | 2,276 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Multi-List boxes and navigation

I'm developing an A2K adp that contains doctor info and the months
they are not available for teaching. A doctor can be unavailable for
some months for one year and other months for another year. I want
the user to enter the year then use a multi-select list box to choose
the months not available, then go to a fresh screen, enter another
year and choose the months not available for that year, and so on. In
the table, there is one record per year/month per doctor.

I've got the form set up and I can enter one year and the months but
can't figure out how to navigate to a fresh screen and enter the next
year. Maybe using a multi-select listbox isn't the way to go??? Any
ideas? Thanks.
Nov 12 '05 #1
2 2026
Ellen Manning wrote:
I'm developing an A2K adp that contains doctor info and the months
they are not available for teaching. A doctor can be unavailable for
some months for one year and other months for another year. I want
the user to enter the year then use a multi-select list box to choose
the months not available, then go to a fresh screen, enter another
year and choose the months not available for that year, and so on. In
the table, there is one record per year/month per doctor.

I've got the form set up and I can enter one year and the months but
can't figure out how to navigate to a fresh screen and enter the next
year. Maybe using a multi-select listbox isn't the way to go??? Any
ideas? Thanks.


Why not? I am not sure how many columns you have. You can see in my
example I use 0 as the first column is the column I want to use (the
column property starts at zero so if you have 5 columns, it is 0-4).

I would have a button to update the months to igrnore in the table.
Let's say your table has the fields called DoctorID, YearAvail, and the
months are Yes/No for availability and are called Jan...Dec. On the
form you have a DoctorID field you are working on, the YearAvail. The
listbox name is called ListMon. The listbox has 1 column; Jan...Dec

Sub CommandSelectAv ailability_Clic k

'no need to process if doctorid or year is empty.
If IsNull(Me.Docto rID) Or IsNull(Me.YearA vail) Then Exit Sub

Dim var As Variant
Dim strMon As STring
Dim intFor As Integer
Dim intYear As Integer
Dim rst As DAO.Recordset

Set rst = Currentdb.openr ecordset("Avail ability",dbopen dynaset)

'find the doctor record for the year
rst.findfirst "DoctorID = " & Me.DoctorID & " And " _
"YearAvail = " & Me.YearAvail

'if found, edit the availablity record else add one.
If not rst.nomatch then
rst.Edit
Else
'if not found, create a new record
rst.AddNew
rst!DoctorID = Me.DoctorID
rst!Year = Me.YearAvail
Endif

'if editing, clear out any settings first
intYear = Year(Date())
For intFor = 1 to 12
'assign to variable Jan-Dec
strMon = Format(DateSeri al(intYear,intF or,1),"mmm")

'now set that month to false
rst(strMon) = False
Next

'loop through all selected months and set to Available = True
For Each var In Me.ListMon.Item sSelected
'assign the month to true
strMon = Me.ListMon.Colu mn(0, var)
rst(strMon) = True

'now de-select that month
Me.ListMon.Sele cted(var) = False
Next

'commit the changes and close recordset
rst.Update
rst.close
set rst = Nothing

'clear out the Year
Me.YearAvail = Null

'keep the same doctor. go to the doctor field
Me.DoctorID.Set Focus
End Sub

I would probably have a routine that once a doctorID and Year is
entered to see if the record exists and set the Selected property to
true so you can see what has already been selected. I've provided
enough code for you to see how that can be done. Instead of looping
through the list of ItemsSeleted, you would do a loop using
For I = 0 TO Me.ListMOn.List Count -1
...set month to true or false for existing records
Next
Nov 12 '05 #2
Ellen Manning wrote:
I'm developing an A2K adp that contains doctor info and the months
they are not available for teaching. A doctor can be unavailable for
some months for one year and other months for another year. I want
the user to enter the year then use a multi-select list box to choose
the months not available, then go to a fresh screen, enter another
year and choose the months not available for that year, and so on. In
the table, there is one record per year/month per doctor.

I've got the form set up and I can enter one year and the months but
can't figure out how to navigate to a fresh screen and enter the next
year. Maybe using a multi-select listbox isn't the way to go??? Any
ideas? Thanks.


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

The list box method of selecting months is OK, but you have to know that
all the selected values (records) will have to be written to the table
one-at-a-time. You can use a stored procedure (SP) & VBA code. Example
of the SP:

CREATE PROCEDURE usp_AddDoctorUn available
- -- If the DoctorNotAvaila ble table has more than these columns
- -- you will have to adjust the SP & the VBA code to insert those
- -- columns.

@DoctorID INTEGER ,
@Month DATETIME -- Format YYYYMM01

AS

INSERT INTO DoctorNotAvaila ble (DoctorID, Month)
VALUES (@DoctorID, @Month)

====

There should be a CommandButton on the form that saves the data to the
table "DoctorNotAvail able" (use the real table's name). E.g.
(untested):

Private Sub cmdSave_Click()
' In:
' Me!lstMonths The months to save
' Me!txtDoctorID The doctor's ID
' Me!txtYear The year the months are in
'

Dim cn As New ADODB.Connectio n
Dim strSQL As String
Dim strExec As String
Dim varRow as Variant

On Error GoTo err_

cn.Connection = CurrentProject. Connection
cn.Open

strSQL = "EXEC usp_AddDoctorUn available " & Me!txtDoctorID & ", "

' Assumes the list box's bound column returns the month number,
' and that txtYear holds a 4-digit year.
For Each varRow In Me!lstMonths.It emsSelected
With Me!lstMonths
' Format the date to "YYYYMM01" & attach to EXEC statement.
' Note: single quotes have to surround the date value.
strExec = strSQL & " '" & Me!txtYear & _
Format(.ItemDat a(varRow),"00") & "01'"
cn.Execute strExec,,adCmdT ext
End With
Next varRow

' If reached here - success!
' Clear the selected values from the list box
' to show the user that the info was saved.
' Or show a MsgBox saying saved.
With Me!lstMonths
For Each varRow In .ItemsSelected
.Selected(varRo w) = False
Next varRow
End With

exit_:
cn.Close
Set cn = Nothing
Exit Sub

err_:
' You may want to check for duplicates & just Resume Next
' instead of running the MsgBox.
MsgBox "An error occurred while saving the Doctor's " & _
"Unavailabl e months" & vbcr & vbcr & "Error: " & _
err.Description , vbCritical
Resume exit_

End Sub

--
MGFoster:::mgf0 0 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQH2udYechKq OuFEgEQK7ygCgkH fBI/HrAT4myW0qLQ50a eXwuOgAoLeY
rE92g44aXedjv29 46IxhwxIY
=kzJ9
-----END PGP SIGNATURE-----

Nov 12 '05 #3

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

Similar topics

37
4891
by: ajikoe | last post by:
Hello, Is anyone has experiance in running python code to run multi thread parallel in multi processor. Is it possible ? Can python manage which cpu shoud do every thread? Sincerely Yours, Pujo
4
4670
by: Frank Jona | last post by:
Intellisense with C# and a multi-file assembly is not working. With VB.NET it is working. Is there a fix availible? We're using VisualStudio 2003 Regards Frank
12
3877
by: * ProteanThread * | last post by:
but depends upon the clique: http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=954drf%24oca%241%40agate.berkeley.edu&rnum=2&prev=/groups%3Fq%3D%2522cross%2Bposting%2Bversus%2Bmulti%2Bposting%2522%26ie%3DUTF-8%26oe%3DUTF-8%26hl%3Den ...
0
3780
by: frankenberry | last post by:
I have multi-page tiff files. I need to extract individual frames from the multi-page tiffs and save them as single-page tiffs. 95% of the time I receive multi-page tiffs containing 1 or more black and white CCITT4 compressed files (frames) inside the tiff. Every now and then I receive a mixture of black and white CCITT4 and JPEG compressed files, and sometimes just multi-page tiffs with JPEG only. The code runs great when dealing with the...
6
8172
by: cody | last post by:
What are multi file assemblies good for? What are the advantages of using multiple assemblies (A.DLL+B.DLL) vs. a single multi file assembly (A.DLL+A.NETMODULE)?
4
17872
by: mimmo | last post by:
Hi! I should convert the accented letters of a string in the correspondent letters not accented. But when I compile with -Wall it give me: warning: multi-character character constant Do the problem is the charset? How I can avoid this warning? But the worst thing isn't the warning, but that the program doesn't work! The program execute all other operations well, but it don't print the converted letters: for example, in the string...
5
5992
by: Shane Story | last post by:
I can seem to get the dimensions of a frame in a multiframe tiff. After selecting activeframe, the Width/Height is still really much larger than the page's actual dimensions. When I split a TIFF to several PNG files this causes a problem, becuase the resulting image is (the page to the far left and a lot of black space surrounding it and a filesize that is larger than needed. Any ideas?
5
5765
by: bobwansink | last post by:
Hi, I'm relatively new to programming and I would like to create a C++ multi user program. It's for a project for school. This means I will have to write a paper about the theory too. Does anyone know a good place to start looking for some theory on the subject of multi user applications? I know only bits and pieces, like about transactions, but a compendium of possible approches to multi user programming would be very appreciated!
0
2327
by: Sabri.Pllana | last post by:
We apologize if you receive multiple copies of this call for papers. *********************************************************************** 2008 International Workshop on Multi-Core Computing Systems (MuCoCoS'08) Barcelona, Spain, March 4 - 7, 2008; in conjunction with CISIS'08. <http://www.par.univie.ac.at/~pllana/mucocos08> *********************************************************************** Context
1
9313
by: mknoll217 | last post by:
I am recieving this error from my code: The multi-part identifier "PAR.UniqueID" could not be bound. The multi-part identifier "Salary.UniqueID" could not be bound. The multi-part identifier "PAR.UniqueID" could not be bound. The multi-part identifier "PAR.PAR_Status" could not be bound. The multi-part identifier "Salary.New_Salary" could not be bound. The multi-part identifier "Salary.UniqueID" could not be bound. The multi-part...
0
8752
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9401
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...
1
9179
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
9116
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
8099
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...
0
6011
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4519
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
3228
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
2637
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.