The reason it complains is pretty simple. If I cut down your code a bit it's a clearer:
Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
Dim UserRoles As String
Dim reader As OleDbDataReader = command.ExecuteReader()
Do While reader.Read()
UserRoles = reader.Item(1)
Loop
If UserRoles = "1" Then
LibrarySoftForm.Show()
End If
End Sub
The compiler can see a route through your code where
UserRoles
is never assigned a value before it reaches the
If
condition - basically, if the reader returns no rows. If your code takes that path at run time, then a null reference exception would be thrown, so it is letting you know before you get a problem in six months time.
Either check for
Nothing
as well as a specific value, or assign a default value when you define the variable which will "force" it to take the path you want if there are no rows.